idx int64 0 252k | question stringlengths 48 5.28k | target stringlengths 5 1.23k |
|---|---|---|
243,400 | def filter_data ( data , kernel , mode = 'constant' , fill_value = 0.0 , check_normalization = False ) : from scipy import ndimage if kernel is not None : if isinstance ( kernel , Kernel2D ) : kernel_array = kernel . array else : kernel_array = kernel if check_normalization : if not np . allclose ( np . sum ( kernel_ar... | Convolve a 2D image with a 2D kernel . |
243,401 | def prepare_psf_model ( psfmodel , xname = None , yname = None , fluxname = None , renormalize_psf = True ) : if xname is None : xinmod = models . Shift ( 0 , name = 'x_offset' ) xname = 'offset_0' else : xinmod = models . Identity ( 1 ) xname = xname + '_2' xinmod . fittable = True if yname is None : yinmod = models .... | Convert a 2D PSF model to one suitable for use with BasicPSFPhotometry or its subclasses . |
243,402 | def get_grouped_psf_model ( template_psf_model , star_group , pars_to_set ) : group_psf = None for star in star_group : psf_to_add = template_psf_model . copy ( ) for param_tab_name , param_name in pars_to_set . items ( ) : setattr ( psf_to_add , param_name , star [ param_tab_name ] ) if group_psf is None : group_psf =... | Construct a joint PSF model which consists of a sum of PSF s templated on a specific model but whose parameters are given by a table of objects . |
243,403 | def _call_fitter ( fitter , psf , x , y , data , weights ) : if np . all ( weights == 1. ) : return fitter ( psf , x , y , data ) else : return fitter ( psf , x , y , data , weights = weights ) | Not all fitters have to support a weight array . This function includes the weight in the fitter call only if really needed . |
243,404 | def detect_threshold ( data , snr , background = None , error = None , mask = None , mask_value = None , sigclip_sigma = 3.0 , sigclip_iters = None ) : if background is None or error is None : if astropy_version < '3.1' : data_mean , data_median , data_std = sigma_clipped_stats ( data , mask = mask , mask_value = mask_... | Calculate a pixel - wise threshold image that can be used to detect sources . |
243,405 | def run_cmd ( cmd ) : try : p = sp . Popen ( cmd , stdout = sp . PIPE , stderr = sp . PIPE ) stdout , stderr = p . communicate ( ) except OSError as e : if DEBUG : raise if e . errno == errno . ENOENT : msg = 'Command not found: `{0}`' . format ( ' ' . join ( cmd ) ) raise _CommandNotFound ( msg , cmd ) else : raise _A... | Run a command in a subprocess given as a list of command - line arguments . |
243,406 | def to_sky ( self , wcs , mode = 'all' ) : sky_params = self . _to_sky_params ( wcs , mode = mode ) return SkyEllipticalAperture ( ** sky_params ) | Convert the aperture to a SkyEllipticalAperture object defined in celestial coordinates . |
243,407 | def to_sky ( self , wcs , mode = 'all' ) : sky_params = self . _to_sky_params ( wcs , mode = mode ) return SkyEllipticalAnnulus ( ** sky_params ) | Convert the aperture to a SkyEllipticalAnnulus object defined in celestial coordinates . |
243,408 | def to_pixel ( self , wcs , mode = 'all' ) : pixel_params = self . _to_pixel_params ( wcs , mode = mode ) return EllipticalAperture ( ** pixel_params ) | Convert the aperture to an EllipticalAperture object defined in pixel coordinates . |
243,409 | def to_pixel ( self , wcs , mode = 'all' ) : pixel_params = self . _to_pixel_params ( wcs , mode = mode ) return EllipticalAnnulus ( ** pixel_params ) | Convert the aperture to an EllipticalAnnulus object defined in pixel coordinates . |
243,410 | def _area ( sma , eps , phi , r ) : aux = r * math . cos ( phi ) / sma signal = aux / abs ( aux ) if abs ( aux ) >= 1. : aux = signal return abs ( sma ** 2 * ( 1. - eps ) / 2. * math . acos ( aux ) ) | Compute elliptical sector area . |
243,411 | def find_center ( self , image , threshold = 0.1 , verbose = True ) : self . _centerer_mask_half_size = len ( IN_MASK ) / 2 self . centerer_threshold = threshold sz = len ( IN_MASK ) self . _centerer_ones_in = np . ma . masked_array ( np . ones ( shape = ( sz , sz ) ) , mask = IN_MASK ) self . _centerer_ones_out = np .... | Find the center of a galaxy . |
243,412 | def radius ( self , angle ) : return ( self . sma * ( 1. - self . eps ) / np . sqrt ( ( ( 1. - self . eps ) * np . cos ( angle ) ) ** 2 + ( np . sin ( angle ) ) ** 2 ) ) | Calculate the polar radius for a given polar angle . |
243,413 | def initialize_sector_geometry ( self , phi ) : sma1 , sma2 = self . bounding_ellipses ( ) eps_ = 1. - self . eps self . _phi1 = phi - self . sector_angular_width / 2. r1 = ( sma1 * eps_ / math . sqrt ( ( eps_ * math . cos ( self . _phi1 ) ) ** 2 + ( math . sin ( self . _phi1 ) ) ** 2 ) ) r2 = ( sma2 * eps_ / math . sq... | Initialize geometry attributes associated with an elliptical sector at the given polar angle phi . |
243,414 | def bounding_ellipses ( self ) : if ( self . linear_growth ) : a1 = self . sma - self . astep / 2. a2 = self . sma + self . astep / 2. else : a1 = self . sma * ( 1. - self . astep / 2. ) a2 = self . sma * ( 1. + self . astep / 2. ) return a1 , a2 | Compute the semimajor axis of the two ellipses that bound the annulus where integrations take place . |
243,415 | def update_sma ( self , step ) : if self . linear_growth : sma = self . sma + step else : sma = self . sma * ( 1. + step ) return sma | Calculate an updated value for the semimajor axis given the current value and the step value . |
243,416 | def reset_sma ( self , step ) : if self . linear_growth : sma = self . sma - step step = - step else : aux = 1. / ( 1. + step ) sma = self . sma * aux step = aux - 1. return sma , step | Change the direction of semimajor axis growth from outwards to inwards . |
243,417 | def resize_psf ( psf , input_pixel_scale , output_pixel_scale , order = 3 ) : from scipy . ndimage import zoom ratio = input_pixel_scale / output_pixel_scale return zoom ( psf , ratio , order = order ) / ratio ** 2 | Resize a PSF using spline interpolation of the requested order . |
243,418 | def _select_meshes ( self , data ) : nmasked = np . ma . count_masked ( data , axis = 1 ) threshold_npixels = self . exclude_percentile / 100. * self . box_npixels mesh_idx = np . where ( ( nmasked <= threshold_npixels ) & ( nmasked != self . box_npixels ) ) [ 0 ] if len ( mesh_idx ) == 0 : raise ValueError ( 'All mesh... | Define the x and y indices with respect to the low - resolution mesh image of the meshes to use for the background interpolation . |
243,419 | def _prepare_data ( self ) : self . nyboxes = self . data . shape [ 0 ] // self . box_size [ 0 ] self . nxboxes = self . data . shape [ 1 ] // self . box_size [ 1 ] yextra = self . data . shape [ 0 ] % self . box_size [ 0 ] xextra = self . data . shape [ 1 ] % self . box_size [ 1 ] if ( xextra + yextra ) == 0 : data_ma... | Prepare the data . |
243,420 | def _make_2d_array ( self , data ) : if data . shape != self . mesh_idx . shape : raise ValueError ( 'data and mesh_idx must have the same shape' ) if np . ma . is_masked ( data ) : raise ValueError ( 'data must not be a masked array' ) data2d = np . zeros ( self . _mesh_shape ) . astype ( data . dtype ) data2d [ self ... | Convert a 1D array of mesh values to a masked 2D mesh array given the 1D mesh indices mesh_idx . |
243,421 | def _interpolate_meshes ( self , data , n_neighbors = 10 , eps = 0. , power = 1. , reg = 0. ) : yx = np . column_stack ( [ self . mesh_yidx , self . mesh_xidx ] ) coords = np . array ( list ( product ( range ( self . nyboxes ) , range ( self . nxboxes ) ) ) ) f = ShepardIDWInterpolator ( yx , data ) img1d = f ( coords ... | Use IDW interpolation to fill in any masked pixels in the low - resolution 2D mesh background and background RMS images . |
243,422 | def _selective_filter ( self , data , indices ) : data_out = np . copy ( data ) for i , j in zip ( * indices ) : yfs , xfs = self . filter_size hyfs , hxfs = yfs // 2 , xfs // 2 y0 , y1 = max ( i - hyfs , 0 ) , min ( i - hyfs + yfs , data . shape [ 0 ] ) x0 , x1 = max ( j - hxfs , 0 ) , min ( j - hxfs + xfs , data . sh... | Selectively filter only pixels above filter_threshold in the background mesh . |
243,423 | def _filter_meshes ( self ) : from scipy . ndimage import generic_filter try : nanmedian_func = np . nanmedian except AttributeError : from scipy . stats import nanmedian nanmedian_func = nanmedian if self . filter_threshold is None : self . background_mesh = generic_filter ( self . background_mesh , nanmedian_func , s... | Apply a 2D median filter to the low - resolution 2D mesh including only pixels inside the image at the borders . |
243,424 | def _calc_bkg_bkgrms ( self ) : if self . sigma_clip is not None : data_sigclip = self . sigma_clip ( self . _mesh_data , axis = 1 ) else : data_sigclip = self . _mesh_data del self . _mesh_data idx = self . _select_meshes ( data_sigclip ) self . mesh_idx = self . mesh_idx [ idx ] self . _data_sigclip = data_sigclip [ ... | Calculate the background and background RMS estimate in each of the meshes . |
243,425 | def _calc_coordinates ( self ) : self . y = ( self . mesh_yidx * self . box_size [ 0 ] + ( self . box_size [ 0 ] - 1 ) / 2. ) self . x = ( self . mesh_xidx * self . box_size [ 1 ] + ( self . box_size [ 1 ] - 1 ) / 2. ) self . yx = np . column_stack ( [ self . y , self . x ] ) nx , ny = self . data . shape self . data_c... | Calculate the coordinates to use when calling an interpolator . |
243,426 | def plot_meshes ( self , ax = None , marker = '+' , color = 'blue' , outlines = False , ** kwargs ) : import matplotlib . pyplot as plt kwargs [ 'color' ] = color if ax is None : ax = plt . gca ( ) ax . scatter ( self . x , self . y , marker = marker , color = color ) if outlines : from . . aperture import RectangularA... | Plot the low - resolution mesh boxes on a matplotlib Axes instance . |
243,427 | def extract ( self ) : if self . values is not None : return self . values else : s = self . _extract ( ) self . values = s return s | Extract sample data by scanning an elliptical path over the image array . |
243,428 | def update ( self ) : step = self . geometry . astep s = self . extract ( ) self . mean = np . mean ( s [ 2 ] ) gradient , gradient_error = self . _get_gradient ( step ) previous_gradient = self . gradient if not previous_gradient : previous_gradient = - 0.05 if gradient >= ( previous_gradient / 3. ) : gradient , gradi... | Update this ~photutils . isophote . EllipseSample instance . |
243,429 | def fit ( self , conver = DEFAULT_CONVERGENCE , minit = DEFAULT_MINIT , maxit = DEFAULT_MAXIT , fflag = DEFAULT_FFLAG , maxgerr = DEFAULT_MAXGERR , going_inwards = False ) : sample = self . _sample lexceed = False minimum_amplitude_value = np . Inf minimum_amplitude_sample = None for iter in range ( maxit ) : sample . ... | Fit an elliptical isophote . |
243,430 | def _extract_stars ( data , catalog , size = ( 11 , 11 ) , use_xy = True ) : colnames = catalog . colnames if ( 'x' not in colnames or 'y' not in colnames ) or not use_xy : xcenters , ycenters = skycoord_to_pixel ( catalog [ 'skycoord' ] , data . wcs , origin = 0 , mode = 'all' ) else : xcenters = catalog [ 'x' ] . dat... | Extract cutout images from a single image centered on stars defined in the single input catalog . |
243,431 | def estimate_flux ( self ) : from . epsf import _interpolate_missing_data if np . any ( self . mask ) : data_interp = _interpolate_missing_data ( self . data , method = 'cubic' , mask = self . mask ) data_interp = _interpolate_missing_data ( data_interp , method = 'nearest' , mask = self . mask ) flux = np . sum ( data... | Estimate the star s flux by summing values in the input cutout array . |
243,432 | def _xy_idx ( self ) : yidx , xidx = np . indices ( self . _data . shape ) return xidx [ ~ self . mask ] . ravel ( ) , yidx [ ~ self . mask ] . ravel ( ) | 1D arrays of x and y indices of unmasked pixels in the cutout reference frame . |
243,433 | def find_group ( self , star , starlist ) : star_distance = np . hypot ( star [ 'x_0' ] - starlist [ 'x_0' ] , star [ 'y_0' ] - starlist [ 'y_0' ] ) distance_criteria = star_distance < self . crit_separation return np . asarray ( starlist [ distance_criteria ] [ 'id' ] ) | Find the ids of those stars in starlist which are at a distance less than crit_separation from star . |
243,434 | def _from_float ( cls , xmin , xmax , ymin , ymax ) : ixmin = int ( np . floor ( xmin + 0.5 ) ) ixmax = int ( np . ceil ( xmax + 0.5 ) ) iymin = int ( np . floor ( ymin + 0.5 ) ) iymax = int ( np . ceil ( ymax + 0.5 ) ) return cls ( ixmin , ixmax , iymin , iymax ) | Return the smallest bounding box that fully contains a given rectangle defined by float coordinate values . |
243,435 | def slices ( self ) : return ( slice ( self . iymin , self . iymax ) , slice ( self . ixmin , self . ixmax ) ) | The bounding box as a tuple of slice objects . |
243,436 | def as_patch ( self , ** kwargs ) : from matplotlib . patches import Rectangle return Rectangle ( xy = ( self . extent [ 0 ] , self . extent [ 2 ] ) , width = self . shape [ 1 ] , height = self . shape [ 0 ] , ** kwargs ) | Return a matplotlib . patches . Rectangle that represents the bounding box . |
243,437 | def to_aperture ( self ) : from . rectangle import RectangularAperture xpos = ( self . extent [ 1 ] + self . extent [ 0 ] ) / 2. ypos = ( self . extent [ 3 ] + self . extent [ 2 ] ) / 2. xypos = ( xpos , ypos ) h , w = self . shape return RectangularAperture ( xypos , w = w , h = h , theta = 0. ) | Return a ~photutils . aperture . RectangularAperture that represents the bounding box . |
243,438 | def plot ( self , origin = ( 0 , 0 ) , ax = None , fill = False , ** kwargs ) : aper = self . to_aperture ( ) aper . plot ( origin = origin , ax = ax , fill = fill , ** kwargs ) | Plot the BoundingBox on a matplotlib ~matplotlib . axes . Axes instance . |
243,439 | def _find_stars ( data , kernel , threshold_eff , min_separation = None , mask = None , exclude_border = False ) : convolved_data = filter_data ( data , kernel . data , mode = 'constant' , fill_value = 0.0 , check_normalization = False ) if min_separation is None : footprint = kernel . mask . astype ( np . bool ) else ... | Find stars in an image . |
243,440 | def roundness2 ( self ) : if np . isnan ( self . hx ) or np . isnan ( self . hy ) : return np . nan else : return 2.0 * ( self . hx - self . hy ) / ( self . hx + self . hy ) | The star roundness . |
243,441 | def detect_sources ( data , threshold , npixels , filter_kernel = None , connectivity = 8 , mask = None ) : from scipy import ndimage if ( npixels <= 0 ) or ( int ( npixels ) != npixels ) : raise ValueError ( 'npixels must be a positive integer, got ' '"{0}"' . format ( npixels ) ) image = ( filter_data ( data , filter... | Detect sources above a specified threshold value in an image and return a ~photutils . segmentation . SegmentationImage object . |
243,442 | def make_source_mask ( data , snr , npixels , mask = None , mask_value = None , filter_fwhm = None , filter_size = 3 , filter_kernel = None , sigclip_sigma = 3.0 , sigclip_iters = 5 , dilate_size = 11 ) : from scipy import ndimage threshold = detect_threshold ( data , snr , background = None , error = None , mask = mas... | Make a source mask using source segmentation and binary dilation . |
243,443 | def data_ma ( self ) : mask = ( self . _segment_img [ self . slices ] != self . label ) return np . ma . masked_array ( self . _segment_img [ self . slices ] , mask = mask ) | A 2D ~numpy . ma . MaskedArray cutout image of the segment using the minimal bounding box . |
243,444 | def _reset_lazy_properties ( self ) : for key , value in self . __class__ . __dict__ . items ( ) : if isinstance ( value , lazyproperty ) : self . __dict__ . pop ( key , None ) | Reset all lazy properties . |
243,445 | def segments ( self ) : segments = [ ] for label , slc in zip ( self . labels , self . slices ) : segments . append ( Segment ( self . data , label , slc , self . get_area ( label ) ) ) return segments | A list of Segment objects . |
243,446 | def get_index ( self , label ) : self . check_labels ( label ) return np . searchsorted ( self . labels , label ) | Find the index of the input label . |
243,447 | def get_indices ( self , labels ) : self . check_labels ( labels ) return np . searchsorted ( self . labels , labels ) | Find the indices of the input labels . |
243,448 | def slices ( self ) : from scipy . ndimage import find_objects return [ slc for slc in find_objects ( self . _data ) if slc is not None ] | A list of tuples where each tuple contains two slices representing the minimal box that contains the labeled region . |
243,449 | def missing_labels ( self ) : return np . array ( sorted ( set ( range ( 0 , self . max_label + 1 ) ) . difference ( np . insert ( self . labels , 0 , 0 ) ) ) ) | A 1D ~numpy . ndarray of the sorted non - zero labels that are missing in the consecutive sequence from zero to the maximum label number . |
243,450 | def reassign_label ( self , label , new_label , relabel = False ) : self . reassign_labels ( label , new_label , relabel = relabel ) | Reassign a label number to a new number . |
243,451 | def reassign_labels ( self , labels , new_label , relabel = False ) : self . check_labels ( labels ) labels = np . atleast_1d ( labels ) if len ( labels ) == 0 : return idx = np . zeros ( self . max_label + 1 , dtype = int ) idx [ self . labels ] = self . labels idx [ labels ] = new_label self . data = idx [ self . dat... | Reassign one or more label numbers . |
243,452 | def relabel_consecutive ( self , start_label = 1 ) : if start_label <= 0 : raise ValueError ( 'start_label must be > 0.' ) if self . is_consecutive and ( self . labels [ 0 ] == start_label ) : return new_labels = np . zeros ( self . max_label + 1 , dtype = np . int ) new_labels [ self . labels ] = np . arange ( self . ... | Reassign the label numbers consecutively such that there are no missing label numbers . |
243,453 | def keep_label ( self , label , relabel = False ) : self . keep_labels ( label , relabel = relabel ) | Keep only the specified label . |
243,454 | def keep_labels ( self , labels , relabel = False ) : self . check_labels ( labels ) labels = np . atleast_1d ( labels ) labels_tmp = list ( set ( self . labels ) - set ( labels ) ) self . remove_labels ( labels_tmp , relabel = relabel ) | Keep only the specified labels . |
243,455 | def remove_label ( self , label , relabel = False ) : self . remove_labels ( label , relabel = relabel ) | Remove the label number . |
243,456 | def remove_labels ( self , labels , relabel = False ) : self . check_labels ( labels ) self . reassign_label ( labels , new_label = 0 ) if relabel : self . relabel_consecutive ( ) | Remove one or more labels . |
243,457 | def remove_border_labels ( self , border_width , partial_overlap = True , relabel = False ) : if border_width >= min ( self . shape ) / 2 : raise ValueError ( 'border_width must be smaller than half the ' 'image size in either dimension' ) border = np . zeros ( self . shape , dtype = np . bool ) border [ : border_width... | Remove labeled segments near the image border . |
243,458 | def remove_masked_labels ( self , mask , partial_overlap = True , relabel = False ) : if mask . shape != self . shape : raise ValueError ( 'mask must have the same shape as the ' 'segmentation image' ) remove_labels = self . _get_labels ( self . data [ mask ] ) if not partial_overlap : interior_labels = self . _get_lab... | Remove labeled segments located within a masked region . |
243,459 | def outline_segments ( self , mask_background = False ) : from scipy . ndimage import grey_erosion , grey_dilation selem = np . array ( [ [ 0 , 1 , 0 ] , [ 1 , 1 , 1 ] , [ 0 , 1 , 0 ] ] ) eroded = grey_erosion ( self . data , footprint = selem , mode = 'constant' , cval = 0. ) dilated = grey_dilation ( self . data , fo... | Outline the labeled segments . |
243,460 | def _overlap_slices ( self , shape ) : if len ( shape ) != 2 : raise ValueError ( 'input shape must have 2 elements.' ) xmin = self . bbox . ixmin xmax = self . bbox . ixmax ymin = self . bbox . iymin ymax = self . bbox . iymax if xmin >= shape [ 1 ] or ymin >= shape [ 0 ] or xmax <= 0 or ymax <= 0 : return None , None... | Calculate the slices for the overlapping part of the bounding box and an array of the given shape . |
243,461 | def to_image ( self , shape ) : if len ( shape ) != 2 : raise ValueError ( 'input shape must have 2 elements.' ) image = np . zeros ( shape ) if self . bbox . ixmin < 0 or self . bbox . iymin < 0 : return self . _to_image_partial_overlap ( image ) try : image [ self . bbox . slices ] = self . data except ValueError : i... | Return an image of the mask in a 2D array of the given shape taking any edge effects into account . |
243,462 | def cutout ( self , data , fill_value = 0. , copy = False ) : data = np . asanyarray ( data ) if data . ndim != 2 : raise ValueError ( 'data must be a 2D array.' ) partial_overlap = False if self . bbox . ixmin < 0 or self . bbox . iymin < 0 : partial_overlap = True if not partial_overlap : if copy : cutout = np . copy... | Create a cutout from the input data over the mask bounding box taking any edge effects into account . |
243,463 | def multiply ( self , data , fill_value = 0. ) : cutout = self . cutout ( data , fill_value = fill_value ) if cutout is None : return None else : return cutout * self . data | Multiply the aperture mask with the input data taking any edge effects into account . |
243,464 | def deblend_sources ( data , segment_img , npixels , filter_kernel = None , labels = None , nlevels = 32 , contrast = 0.001 , mode = 'exponential' , connectivity = 8 , relabel = True ) : if not isinstance ( segment_img , SegmentationImage ) : segment_img = SegmentationImage ( segment_img ) if segment_img . shape != dat... | Deblend overlapping sources labeled in a segmentation image . |
243,465 | def _moments_central ( data , center = None , order = 1 ) : data = np . asarray ( data ) . astype ( float ) if data . ndim != 2 : raise ValueError ( 'data must be a 2D array.' ) if center is None : from . . centroids import centroid_com center = centroid_com ( data ) indices = np . ogrid [ [ slice ( 0 , i ) for i in da... | Calculate the central image moments up to the specified order . |
243,466 | def first_and_second_harmonic_function ( phi , c ) : return ( c [ 0 ] + c [ 1 ] * np . sin ( phi ) + c [ 2 ] * np . cos ( phi ) + c [ 3 ] * np . sin ( 2 * phi ) + c [ 4 ] * np . cos ( 2 * phi ) ) | Compute the harmonic function value used to calculate the corrections for ellipse fitting . |
243,467 | def _radial_distance ( shape ) : if len ( shape ) != 2 : raise ValueError ( 'shape must have only 2 elements' ) position = ( np . asarray ( shape ) - 1 ) / 2. x = np . arange ( shape [ 1 ] ) - position [ 1 ] y = np . arange ( shape [ 0 ] ) - position [ 0 ] xx , yy = np . meshgrid ( x , y ) return np . sqrt ( xx ** 2 + ... | Return an array where each value is the Euclidean distance from the array center . |
243,468 | def load_spitzer_image ( show_progress = False ) : path = get_path ( 'spitzer_example_image.fits' , location = 'remote' , show_progress = show_progress ) hdu = fits . open ( path ) [ 0 ] return hdu | Load a 4 . 5 micron Spitzer image . |
243,469 | def load_spitzer_catalog ( show_progress = False ) : path = get_path ( 'spitzer_example_catalog.xml' , location = 'remote' , show_progress = show_progress ) table = Table . read ( path ) return table | Load a 4 . 5 micron Spitzer catalog . |
243,470 | def load_irac_psf ( channel , show_progress = False ) : channel = int ( channel ) if channel < 1 or channel > 4 : raise ValueError ( 'channel must be 1, 2, 3, or 4' ) fn = 'irac_ch{0}_flight.fits' . format ( channel ) path = get_path ( fn , location = 'remote' , show_progress = show_progress ) hdu = fits . open ( path ... | Load a Spitzer IRAC PSF image . |
243,471 | def fit_image ( self , sma0 = None , minsma = 0. , maxsma = None , step = 0.1 , conver = DEFAULT_CONVERGENCE , minit = DEFAULT_MINIT , maxit = DEFAULT_MAXIT , fflag = DEFAULT_FFLAG , maxgerr = DEFAULT_MAXGERR , sclip = 3. , nclip = 0 , integrmode = BILINEAR , linear = False , maxrit = None ) : isophote_list = [ ] if no... | Fit multiple isophotes to the image array . |
243,472 | def fit_isophote ( self , sma , step = 0.1 , conver = DEFAULT_CONVERGENCE , minit = DEFAULT_MINIT , maxit = DEFAULT_MAXIT , fflag = DEFAULT_FFLAG , maxgerr = DEFAULT_MAXGERR , sclip = 3. , nclip = 0 , integrmode = BILINEAR , linear = False , maxrit = None , noniterate = False , going_inwards = False , isophote_list = N... | Fit a single isophote with a given semimajor axis length . |
243,473 | def to_sky ( self , wcs , mode = 'all' ) : sky_params = self . _to_sky_params ( wcs , mode = mode ) return SkyCircularAperture ( ** sky_params ) | Convert the aperture to a SkyCircularAperture object defined in celestial coordinates . |
243,474 | def to_sky ( self , wcs , mode = 'all' ) : sky_params = self . _to_sky_params ( wcs , mode = mode ) return SkyCircularAnnulus ( ** sky_params ) | Convert the aperture to a SkyCircularAnnulus object defined in celestial coordinates . |
243,475 | def to_pixel ( self , wcs , mode = 'all' ) : pixel_params = self . _to_pixel_params ( wcs , mode = mode ) return CircularAperture ( ** pixel_params ) | Convert the aperture to a CircularAperture object defined in pixel coordinates . |
243,476 | def to_pixel ( self , wcs , mode = 'all' ) : pixel_params = self . _to_pixel_params ( wcs , mode = mode ) return CircularAnnulus ( ** pixel_params ) | Convert the aperture to a CircularAnnulus object defined in pixel coordinates . |
243,477 | def apply_poisson_noise ( data , random_state = None ) : data = np . asanyarray ( data ) if np . any ( data < 0 ) : raise ValueError ( 'data must not contain any negative values' ) prng = check_random_state ( random_state ) return prng . poisson ( data ) | Apply Poisson noise to an array where the value of each element in the input array represents the expected number of counts . |
243,478 | def make_noise_image ( shape , type = 'gaussian' , mean = None , stddev = None , random_state = None ) : if mean is None : raise ValueError ( '"mean" must be input' ) prng = check_random_state ( random_state ) if type == 'gaussian' : if stddev is None : raise ValueError ( '"stddev" must be input for Gaussian noise' ) i... | Make a noise image containing Gaussian or Poisson noise . |
243,479 | def make_random_models_table ( n_sources , param_ranges , random_state = None ) : prng = check_random_state ( random_state ) sources = Table ( ) for param_name , ( lower , upper ) in param_ranges . items ( ) : sources [ param_name ] = prng . uniform ( lower , upper , n_sources ) return sources | Make a ~astropy . table . Table containing randomly generated parameters for an Astropy model to simulate a set of sources . |
243,480 | def make_random_gaussians_table ( n_sources , param_ranges , random_state = None ) : sources = make_random_models_table ( n_sources , param_ranges , random_state = random_state ) if 'flux' in param_ranges and 'amplitude' not in param_ranges : model = Gaussian2D ( x_stddev = 1 , y_stddev = 1 ) if 'x_stddev' in sources .... | Make a ~astropy . table . Table containing randomly generated parameters for 2D Gaussian sources . |
243,481 | def make_model_sources_image ( shape , model , source_table , oversample = 1 ) : image = np . zeros ( shape , dtype = np . float64 ) y , x = np . indices ( shape ) params_to_set = [ ] for param in source_table . colnames : if param in model . param_names : params_to_set . append ( param ) init_params = { param : getatt... | Make an image containing sources generated from a user - specified model . |
243,482 | def make_4gaussians_image ( noise = True ) : table = Table ( ) table [ 'amplitude' ] = [ 50 , 70 , 150 , 210 ] table [ 'x_mean' ] = [ 160 , 25 , 150 , 90 ] table [ 'y_mean' ] = [ 70 , 40 , 25 , 60 ] table [ 'x_stddev' ] = [ 15.2 , 5.1 , 3. , 8.1 ] table [ 'y_stddev' ] = [ 2.6 , 2.5 , 3. , 4.7 ] table [ 'theta' ] = np .... | Make an example image containing four 2D Gaussians plus a constant background . |
243,483 | def make_100gaussians_image ( noise = True ) : n_sources = 100 flux_range = [ 500 , 1000 ] xmean_range = [ 0 , 500 ] ymean_range = [ 0 , 300 ] xstddev_range = [ 1 , 5 ] ystddev_range = [ 1 , 5 ] params = OrderedDict ( [ ( 'flux' , flux_range ) , ( 'x_mean' , xmean_range ) , ( 'y_mean' , ymean_range ) , ( 'x_stddev' , x... | Make an example image containing 100 2D Gaussians plus a constant background . |
243,484 | def make_wcs ( shape , galactic = False ) : wcs = WCS ( naxis = 2 ) rho = np . pi / 3. scale = 0.1 / 3600. if astropy_version < '3.1' : wcs . _naxis1 = shape [ 1 ] wcs . _naxis2 = shape [ 0 ] else : wcs . pixel_shape = shape wcs . wcs . crpix = [ shape [ 1 ] / 2 , shape [ 0 ] / 2 ] wcs . wcs . crval = [ 197.8925 , - 1.... | Create a simple celestial WCS object in either the ICRS or Galactic coordinate frame . |
243,485 | def make_imagehdu ( data , wcs = None ) : data = np . asanyarray ( data ) if data . ndim != 2 : raise ValueError ( 'data must be a 2D array' ) if wcs is not None : header = wcs . to_header ( ) else : header = None return fits . ImageHDU ( data , header = header ) | Create a FITS ~astropy . io . fits . ImageHDU containing the input 2D image . |
243,486 | def centroid_com ( data , mask = None ) : data = data . astype ( np . float ) if mask is not None and mask is not np . ma . nomask : mask = np . asarray ( mask , dtype = bool ) if data . shape != mask . shape : raise ValueError ( 'data and mask must have the same shape.' ) data [ mask ] = 0. badidx = ~ np . isfinite ( ... | Calculate the centroid of an n - dimensional array as its center of mass determined from moments . |
243,487 | def gaussian1d_moments ( data , mask = None ) : if np . any ( ~ np . isfinite ( data ) ) : data = np . ma . masked_invalid ( data ) warnings . warn ( 'Input data contains input values (e.g. NaNs or infs), ' 'which were automatically masked.' , AstropyUserWarning ) else : data = np . ma . array ( data ) if mask is not N... | Estimate 1D Gaussian parameters from the moments of 1D data . |
243,488 | def fit_2dgaussian ( data , error = None , mask = None ) : from . . morphology import data_properties data = np . ma . asanyarray ( data ) if mask is not None and mask is not np . ma . nomask : mask = np . asanyarray ( mask ) if data . shape != mask . shape : raise ValueError ( 'data and mask must have the same shape.'... | Fit a 2D Gaussian plus a constant to a 2D image . |
243,489 | def centroid_1dg ( data , error = None , mask = None ) : data = np . ma . asanyarray ( data ) if mask is not None and mask is not np . ma . nomask : mask = np . asanyarray ( mask ) if data . shape != mask . shape : raise ValueError ( 'data and mask must have the same shape.' ) data . mask |= mask if np . any ( ~ np . i... | Calculate the centroid of a 2D array by fitting 1D Gaussians to the marginal x and y distributions of the array . |
243,490 | def centroid_sources ( data , xpos , ypos , box_size = 11 , footprint = None , error = None , mask = None , centroid_func = centroid_com ) : xpos = np . atleast_1d ( xpos ) ypos = np . atleast_1d ( ypos ) if xpos . ndim != 1 : raise ValueError ( 'xpos must be a 1D array.' ) if ypos . ndim != 1 : raise ValueError ( 'ypo... | Calculate the centroid of sources at the defined positions . |
243,491 | def evaluate ( x , y , constant , amplitude , x_mean , y_mean , x_stddev , y_stddev , theta ) : model = Const2D ( constant ) ( x , y ) + Gaussian2D ( amplitude , x_mean , y_mean , x_stddev , y_stddev , theta ) ( x , y ) return model | Two dimensional Gaussian plus constant function . |
243,492 | def evaluate ( self , x , y , flux , x_0 , y_0 ) : x = ( x - x_0 + 0.5 + self . prf_shape [ 1 ] // 2 ) . astype ( 'int' ) y = ( y - y_0 + 0.5 + self . prf_shape [ 0 ] // 2 ) . astype ( 'int' ) y_sub , x_sub = subpixel_indices ( ( y_0 , x_0 ) , self . subsampling ) x_bound = np . logical_or ( x < 0 , x >= self . prf_sha... | Discrete PRF model evaluation . |
243,493 | def _reproject ( wcs1 , wcs2 ) : import gwcs forward_origin = [ ] if isinstance ( wcs1 , fitswcs . WCS ) : forward = wcs1 . all_pix2world forward_origin = [ 0 ] elif isinstance ( wcs2 , gwcs . wcs . WCS ) : forward = wcs1 . forward_transform else : raise ValueError ( 'wcs1 must be an astropy.wcs.WCS or ' 'gwcs.wcs.WCS ... | Perform the forward transformation of wcs1 followed by the inverse transformation of wcs2 . |
243,494 | def get_version_info ( ) : from astropy import __version__ astropy_version = __version__ from photutils import __version__ photutils_version = __version__ return 'astropy: {0}, photutils: {1}' . format ( astropy_version , photutils_version ) | Return astropy and photutils versions . |
243,495 | def calc_total_error ( data , bkg_error , effective_gain ) : data = np . asanyarray ( data ) bkg_error = np . asanyarray ( bkg_error ) inputs = [ data , bkg_error , effective_gain ] has_unit = [ hasattr ( x , 'unit' ) for x in inputs ] use_units = all ( has_unit ) if any ( has_unit ) and not use_units : raise ValueErro... | Calculate a total error array combining a background - only error array with the Poisson noise of sources . |
243,496 | def to_sky ( self , wcs , mode = 'all' ) : sky_params = self . _to_sky_params ( wcs , mode = mode ) return SkyRectangularAperture ( ** sky_params ) | Convert the aperture to a SkyRectangularAperture object defined in celestial coordinates . |
243,497 | def to_sky ( self , wcs , mode = 'all' ) : sky_params = self . _to_sky_params ( wcs , mode = mode ) return SkyRectangularAnnulus ( ** sky_params ) | Convert the aperture to a SkyRectangularAnnulus object defined in celestial coordinates . |
243,498 | def to_pixel ( self , wcs , mode = 'all' ) : pixel_params = self . _to_pixel_params ( wcs , mode = mode ) return RectangularAperture ( ** pixel_params ) | Convert the aperture to a RectangularAperture object defined in pixel coordinates . |
243,499 | def to_pixel ( self , wcs , mode = 'all' ) : pixel_params = self . _to_pixel_params ( wcs , mode = mode ) return RectangularAnnulus ( ** pixel_params ) | Convert the aperture to a RectangularAnnulus object defined in pixel coordinates . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.