sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def sortSkyCatalog(self):
""" Sort and clip the source catalog based on the flux range specified
by the user. It keeps a copy of the original full list in order to
support iteration.
"""
if len(self.all_radec_orig[2].nonzero()[0]) == 0:
warn_str = "Source catalog NOT... | Sort and clip the source catalog based on the flux range specified
by the user. It keeps a copy of the original full list in order to
support iteration. | entailment |
def match(self,refimage, quiet_identity, **kwargs):
""" Uses xyxymatch to cross-match sources between this catalog and
a reference catalog (refCatalog).
"""
ref_outxy = refimage.outxy
refWCS = refimage.wcs
refname = refimage.name
ref_inxy = refimage.xy_catalog... | Uses xyxymatch to cross-match sources between this catalog and
a reference catalog (refCatalog). | entailment |
def performFit(self,**kwargs):
""" Perform a fit between the matched sources.
Parameters
----------
kwargs : dict
Parameter necessary to perform the fit; namely, *fitgeometry*.
Notes
-----
This task still needs to implemen... | Perform a fit between the matched sources.
Parameters
----------
kwargs : dict
Parameter necessary to perform the fit; namely, *fitgeometry*.
Notes
-----
This task still needs to implement (eventually) interactive iteration of
... | entailment |
def updateHeader(self, wcsname=None, reusename=False):
""" Update header of image with shifts computed by *perform_fit()*.
"""
# Insure filehandle is open and available...
self.openFile()
verbose_level = 1
if not self.perform_update:
verbose_level = 0
... | Update header of image with shifts computed by *perform_fit()*. | entailment |
def writeHeaderlet(self,**kwargs):
""" Write and/or attach a headerlet based on update to PRIMARY WCS
"""
# Insure filehandle is open and available...
self.openFile()
pars = kwargs.copy()
rms_pars = self.fit['rms_keys']
str_kw = ['descrip','history','author','hd... | Write and/or attach a headerlet based on update to PRIMARY WCS | entailment |
def write_skycatalog(self,filename):
""" Write out the all_radec catalog for this image to a file.
"""
if self.all_radec is None:
return
ralist = self.all_radec[0]#.tolist()
declist = self.all_radec[1]#.tolist()
f = open(filename,'w')
f.write("#Sky pos... | Write out the all_radec catalog for this image to a file. | entailment |
def get_xy_catnames(self):
""" Return a string with the names of input_xy catalog names
"""
catstr = self.name+' '
if 'input_xy' in self.catalog_names:
for xycat in self.catalog_names['input_xy']:
catstr += ' '+xycat
return catstr + '\n' | Return a string with the names of input_xy catalog names | entailment |
def write_fit_catalog(self):
""" Write out the catalog of all sources and resids used in the final fit.
"""
if self.pars['writecat']:
log.info('Creating catalog for the fit: {:s}'.format(self.catalog_names['fitmatch']))
f = open(self.catalog_names['fitmatch'],'w')
... | Write out the catalog of all sources and resids used in the final fit. | entailment |
def write_outxy(self,filename):
""" Write out the output(transformed) XY catalog for this image to a file.
"""
f = open(filename,'w')
f.write("#Pixel positions for: "+self.name+'\n')
f.write("#X Y\n")
f.write("#(pix) (pix)\n")
for i in range(self.a... | Write out the output(transformed) XY catalog for this image to a file. | entailment |
def get_shiftfile_row(self):
""" Return the information for a shiftfile for this image to provide
compatability with the IRAF-based MultiDrizzle.
"""
if self.fit is not None:
rowstr = '%s %0.6f %0.6f %0.6f %0.6f %0.6f %0.6f\n'%(
self.name... | Return the information for a shiftfile for this image to provide
compatability with the IRAF-based MultiDrizzle. | entailment |
def clean(self):
""" Remove intermediate files created.
"""
#TODO: add cleaning of mask files, *if* created ...
for f in self.catalog_names:
if 'match' in f:
if os.path.exists(self.catalog_names[f]):
log.info('Deleting intermediate match fi... | Remove intermediate files created. | entailment |
def write_skycatalog(self, filename, show_flux=False, show_id=False):
""" Write out the all_radec catalog for this image to a file.
"""
f = open(filename,'w')
f.write("#Sky positions for cumulative reference catalog. Initial catalog from: "+self.name+'\n')
header1 = "#RA D... | Write out the all_radec catalog for this image to a file. | entailment |
def transformToRef(self):
""" Transform reference catalog sky positions (self.all_radec)
to reference tangent plane (self.wcs) to create output X,Y positions.
"""
if 'refxyunits' in self.pars and self.pars['refxyunits'] == 'pixels':
log.info('Creating RA/Dec positions for ref... | Transform reference catalog sky positions (self.all_radec)
to reference tangent plane (self.wcs) to create output X,Y positions. | entailment |
def clean(self):
""" Remove intermediate files created
"""
if not util.is_blank(self.catalog.catname) and os.path.exists(self.catalog.catname):
os.remove(self.catalog.catname) | Remove intermediate files created | entailment |
def close(self):
""" Close the object nicely and release all the data
arrays from memory YOU CANT GET IT BACK, the pointers
and data are gone so use the getData method to get
the data array returned for future use. You can use
putData to reattach a new data array ... | Close the object nicely and release all the data
arrays from memory YOU CANT GET IT BACK, the pointers
and data are gone so use the getData method to get
the data array returned for future use. You can use
putData to reattach a new data array to the imageObject. | entailment |
def clean(self):
""" Deletes intermediate products generated for this imageObject.
"""
clean_files = ['blotImage','crmaskImage','finalMask',
'staticMask','singleDrizMask','outSky',
'outSContext','outSWeight','outSingle',
'ou... | Deletes intermediate products generated for this imageObject. | entailment |
def getData(self,exten=None):
""" Return just the data array from the specified extension
fileutil is used instead of fits to account for non-
FITS input images. openImage returns a fits object.
"""
if exten.lower().find('sci') > -1:
# For SCI extensions, the ... | Return just the data array from the specified extension
fileutil is used instead of fits to account for non-
FITS input images. openImage returns a fits object. | entailment |
def getHeader(self,exten=None):
""" Return just the specified header extension fileutil
is used instead of fits to account for non-FITS
input images. openImage returns a fits object.
"""
_image=fileutil.openImage(self._filename, clobber=False, memmap=False)
_heade... | Return just the specified header extension fileutil
is used instead of fits to account for non-FITS
input images. openImage returns a fits object. | entailment |
def updateData(self,exten,data):
""" Write out updated data and header to
the original input file for this object.
"""
_extnum=self._interpretExten(exten)
fimg = fileutil.openImage(self._filename, mode='update', memmap=False)
fimg[_extnum].data = data
fimg[_ex... | Write out updated data and header to
the original input file for this object. | entailment |
def putData(self,data=None,exten=None):
""" Now that we are removing the data from the object to save memory,
we need something that cleanly puts the data array back into
the object so that we can write out everything together using
something like fits.writeto....this method... | Now that we are removing the data from the object to save memory,
we need something that cleanly puts the data array back into
the object so that we can write out everything together using
something like fits.writeto....this method is an attempt to
make sure that when yo... | entailment |
def getAllData(self,extname=None,exclude=None):
""" This function is meant to make it easier to attach ALL the data
extensions of the image object so that we can write out copies of
the original image nicer.
If no extname is given, the it retrieves all data from the original... | This function is meant to make it easier to attach ALL the data
extensions of the image object so that we can write out copies of
the original image nicer.
If no extname is given, the it retrieves all data from the original
file and attaches it. Otherwise, give the name ... | entailment |
def returnAllChips(self,extname=None,exclude=None):
""" Returns a list containing all the chips which match the
extname given minus those specified for exclusion (if any).
"""
extensions = self._findExtnames(extname=extname,exclude=exclude)
chiplist = []
for i in rang... | Returns a list containing all the chips which match the
extname given minus those specified for exclusion (if any). | entailment |
def _findExtnames(self, extname=None, exclude=None):
""" This method builds a list of all extensions which have 'EXTNAME'==extname
and do not include any extensions with 'EXTNAME'==exclude, if any are
specified for exclusion at all.
"""
#make a list of the available exten... | This method builds a list of all extensions which have 'EXTNAME'==extname
and do not include any extensions with 'EXTNAME'==exclude, if any are
specified for exclusion at all. | entailment |
def findExtNum(self, extname=None, extver=1):
"""Find the extension number of the give extname and extver."""
extnum = None
extname = extname.upper()
if not self._isSimpleFits:
for ext in self._image:
if (hasattr(ext,'_extension') and 'IMAGE' in ext._extensio... | Find the extension number of the give extname and extver. | entailment |
def _assignRootname(self, chip):
""" Assign a unique rootname for the image based in the expname. """
extname=self._image[self.scienceExt,chip].header["EXTNAME"].lower()
extver=self._image[self.scienceExt,chip].header["EXTVER"]
expname = self._rootname
# record extension-based n... | Assign a unique rootname for the image based in the expname. | entailment |
def _setOutputNames(self,rootname,suffix='_drz'):
""" Define the default output filenames for drizzle products,
these are based on the original rootname of the image
filename should be just 1 filename, so call this in a loop
for chip names contained inside a file.
"""... | Define the default output filenames for drizzle products,
these are based on the original rootname of the image
filename should be just 1 filename, so call this in a loop
for chip names contained inside a file. | entailment |
def _initVirtualOutputs(self):
""" Sets up the structure to hold all the output data arrays for
this image in memory.
"""
self.virtualOutputs = {}
for product in self.outputNames:
self.virtualOutputs[product] = None | Sets up the structure to hold all the output data arrays for
this image in memory. | entailment |
def saveVirtualOutputs(self,outdict):
""" Assign in-memory versions of generated products for this
``imageObject`` based on dictionary 'outdict'.
"""
if not self.inmemory:
return
for outname in outdict:
self.virtualOutputs[outname] = outdict[outname] | Assign in-memory versions of generated products for this
``imageObject`` based on dictionary 'outdict'. | entailment |
def getOutputName(self,name):
""" Return the name of the file or PyFITS object associated with that
name, depending on the setting of self.inmemory.
"""
val = self.outputNames[name]
if self.inmemory: # if inmemory was turned on...
# return virtualOutput object saved w... | Return the name of the file or PyFITS object associated with that
name, depending on the setting of self.inmemory. | entailment |
def updateOutputValues(self,output_wcs):
""" Copy info from output WCSObject into outputnames for each chip
for use in creating outputimage object.
"""
outputvals = self.outputValues
outputvals['output'] = output_wcs.outputNames['outFinal']
outputvals['outnx'], outputval... | Copy info from output WCSObject into outputnames for each chip
for use in creating outputimage object. | entailment |
def updateContextImage(self, contextpar):
""" Reset the name of the context image to `None` if parameter
``context`` is `False`.
"""
self.createContext = contextpar
if not contextpar:
log.info('No context image will be created for %s' %
self._fil... | Reset the name of the context image to `None` if parameter
``context`` is `False`. | entailment |
def find_DQ_extension(self):
""" Return the suffix for the data quality extension and the name of
the file which that DQ extension should be read from.
"""
dqfile = None
dq_suffix=None
if(self.maskExt is not None):
for hdu in self._image:
# Loo... | Return the suffix for the data quality extension and the name of
the file which that DQ extension should be read from. | entailment |
def getKeywordList(self, kw):
"""
Return lists of all attribute values for all active chips in the
``imageObject``.
"""
kwlist = []
for chip in range(1,self._numchips+1,1):
sci_chip = self._image[self.scienceExt,chip]
if sci_chip.group_member:
... | Return lists of all attribute values for all active chips in the
``imageObject``. | entailment |
def getflat(self, chip):
"""
Method for retrieving a detector's flat field.
Returns
-------
flat: array
This method will return an array the same shape as the image in
**units of electrons**.
"""
sci_chip = self._image[self.scienceExt, ch... | Method for retrieving a detector's flat field.
Returns
-------
flat: array
This method will return an array the same shape as the image in
**units of electrons**. | entailment |
def getReadNoiseImage(self, chip):
"""
Notes
=====
Method for returning the readnoise image of a detector
(in electrons).
The method will return an array of the same shape as the image.
:units: electrons
"""
sci_chip = self._image[self.scienceEx... | Notes
=====
Method for returning the readnoise image of a detector
(in electrons).
The method will return an array of the same shape as the image.
:units: electrons | entailment |
def getexptimeimg(self,chip):
"""
Notes
=====
Return an array representing the exposure time per pixel for the detector.
This method will be overloaded for IR detectors which have their own
EXP arrays, namely, WFC3/IR and NICMOS images.
:units:
None
... | Notes
=====
Return an array representing the exposure time per pixel for the detector.
This method will be overloaded for IR detectors which have their own
EXP arrays, namely, WFC3/IR and NICMOS images.
:units:
None
Returns
=======
exptimeimg :... | entailment |
def getdarkimg(self,chip):
"""
Notes
=====
Return an array representing the dark image for the detector.
The method will return an array of the same shape as the image.
:units: electrons
"""
sci_chip = self._image[self.scienceExt,chip]
return np.... | Notes
=====
Return an array representing the dark image for the detector.
The method will return an array of the same shape as the image.
:units: electrons | entailment |
def getskyimg(self,chip):
"""
Notes
=====
Return an array representing the sky image for the detector. The value
of the sky is what would actually be subtracted from the exposure by
the skysub step.
:units: electrons
"""
sci_chip = self._image[s... | Notes
=====
Return an array representing the sky image for the detector. The value
of the sky is what would actually be subtracted from the exposure by
the skysub step.
:units: electrons | entailment |
def getExtensions(self, extname='SCI', section=None):
""" Return the list of EXTVER values for extensions with name specified
in extname.
"""
if section is None:
numext = 0
section = []
for hdu in self._image:
if 'extname' in hdu.heade... | Return the list of EXTVER values for extensions with name specified
in extname. | entailment |
def _countEXT(self,extname="SCI"):
""" Count the number of extensions in the file with the given name
(``EXTNAME``).
"""
count=0 #simple fits image
if (self._image['PRIMARY'].header["EXTEND"]):
for i,hdu in enumerate(self._image):
if i > 0:
... | Count the number of extensions in the file with the given name
(``EXTNAME``). | entailment |
def buildMask(self,chip,bits=0,write=False):
"""
Build masks as specified in the user parameters found in the
configObj object.
We should overload this function in the instrument specific
implementations so that we can add other stuff to the badpixel
mask? Like vignettin... | Build masks as specified in the user parameters found in the
configObj object.
We should overload this function in the instrument specific
implementations so that we can add other stuff to the badpixel
mask? Like vignetting areas and chip boundries in nicmos which
are camera dep... | entailment |
def buildEXPmask(self, chip, dqarr):
""" Builds a weight mask from an input DQ array and the exposure time
per pixel for this chip.
"""
log.info("Applying EXPTIME weighting to DQ mask for chip %s" %
chip)
#exparr = self.getexptimeimg(chip)
exparr = self._... | Builds a weight mask from an input DQ array and the exposure time
per pixel for this chip. | entailment |
def buildIVMmask(self ,chip, dqarr, scale):
""" Builds a weight mask from an input DQ array and either an IVM array
provided by the user or a self-generated IVM array derived from the
flat-field reference file associated with the input image.
"""
sci_chip = self._image[self.scien... | Builds a weight mask from an input DQ array and either an IVM array
provided by the user or a self-generated IVM array derived from the
flat-field reference file associated with the input image. | entailment |
def buildERRmask(self,chip,dqarr,scale):
"""
Builds a weight mask from an input DQ array and an ERR array
associated with the input image.
"""
sci_chip = self._image[self.scienceExt,chip]
# Set default value in case of error, or lack of ERR array
errmask = dqarr
... | Builds a weight mask from an input DQ array and an ERR array
associated with the input image. | entailment |
def set_mt_wcs(self, image):
""" Reset the WCS for this image based on the WCS information from
another imageObject.
"""
for chip in range(1,self._numchips+1,1):
sci_chip = self._image[self.scienceExt,chip]
ref_chip = image._image[image.scienceExt,chip]
... | Reset the WCS for this image based on the WCS information from
another imageObject. | entailment |
def set_wtscl(self, chip, wtscl_par):
""" Sets the value of the wt_scl parameter as needed for drizzling.
"""
sci_chip = self._image[self.scienceExt,chip]
exptime = 1 #sci_chip._exptime
_parval = 'unity'
if wtscl_par is not None:
if type(wtscl_par) == type(''... | Sets the value of the wt_scl parameter as needed for drizzling. | entailment |
def getInstrParameter(self, value, header, keyword):
""" This method gets a instrument parameter from a
pair of task parameters: a value, and a header keyword.
The default behavior is:
- if the value and header keyword are given, raise an exception.
- if the ... | This method gets a instrument parameter from a
pair of task parameters: a value, and a header keyword.
The default behavior is:
- if the value and header keyword are given, raise an exception.
- if the value is given, use it.
- if the value is blank and... | entailment |
def _averageFromHeader(self, header, keyword):
""" Averages out values taken from header. The keywords where
to read values from are passed as a comma-separated list.
"""
_list = ''
for _kw in keyword.split(','):
if _kw in header:
_list = _list + '... | Averages out values taken from header. The keywords where
to read values from are passed as a comma-separated list. | entailment |
def _averageFromList(self, param):
""" Averages out values passed as a comma-separated
list, disregarding the zero-valued entries.
"""
_result = 0.0
_count = 0
for _param in param.split(','):
if _param != '' and float(_param) != 0.0:
_resu... | Averages out values passed as a comma-separated
list, disregarding the zero-valued entries. | entailment |
def compute_wcslin(self,undistort=True):
""" Compute the undistorted WCS based solely on the known distortion
model information associated with the WCS.
"""
for chip in range(1,self._numchips+1,1):
sci_chip = self._image[self.scienceExt,chip]
chip_wcs = sci_ch... | Compute the undistorted WCS based solely on the known distortion
model information associated with the WCS. | entailment |
def set_units(self,chip):
""" Define units for this image.
"""
# Determine output value of BUNITS
# and make sure it is not specified as 'ergs/cm...'
sci_chip = self._image[self.scienceExt,chip]
_bunit = None
if 'BUNIT' in sci_chip.header and sci_chip.header['BUN... | Define units for this image. | entailment |
def getTemplates(fnames, blend=True):
""" Process all headers to produce a set of combined headers
that follows the rules defined by each instrument.
"""
if not blend:
newhdrs = blendheaders.getSingleTemplate(fnames[0])
newtab = None
else:
# apply rules to create final ... | Process all headers to produce a set of combined headers
that follows the rules defined by each instrument. | entailment |
def addWCSKeywords(wcs,hdr,blot=False,single=False,after=None):
""" Update input header 'hdr' with WCS keywords.
"""
wname = wcs.wcs.name
if not single:
wname = 'DRZWCS'
# Update WCS Keywords based on PyDrizzle product's value
# since 'drizzle' itself doesn't update that keyword.
hd... | Update input header 'hdr' with WCS keywords. | entailment |
def writeSingleFITS(data,wcs,output,template,clobber=True,verbose=True):
""" Write out a simple FITS file given a numpy array and the name of another
FITS file to use as a template for the output image header.
"""
outname,outextn = fileutil.parseFilename(output)
outextname,outextver = fileutil.parse... | Write out a simple FITS file given a numpy array and the name of another
FITS file to use as a template for the output image header. | entailment |
def writeDrizKeywords(hdr,imgnum,drizdict):
""" Write basic drizzle-related keywords out to image header as a record
of the processing performed to create the image
The dictionary 'drizdict' will contain the keywords and values to be
written out to the header.
"""
_keyprefix = 'D%03... | Write basic drizzle-related keywords out to image header as a record
of the processing performed to create the image
The dictionary 'drizdict' will contain the keywords and values to be
written out to the header. | entailment |
def writeFITS(self, template, sciarr, whtarr, ctxarr=None,
versions=None, overwrite=yes, blend=True, virtual=False):
"""
Generate PyFITS objects for each output extension
using the file given by 'template' for populating
headers.
The arrays will have the size spe... | Generate PyFITS objects for each output extension
using the file given by 'template' for populating
headers.
The arrays will have the size specified by 'shape'. | entailment |
def find_kwupdate_location(self,hdr,keyword):
"""
Find the last keyword in the output header that comes before the new
keyword in the original, full input headers.
This will rely on the original ordering of keywords from the original input
files in order to place the updated keyw... | Find the last keyword in the output header that comes before the new
keyword in the original, full input headers.
This will rely on the original ordering of keywords from the original input
files in order to place the updated keyword in the correct location in case
the keyword was remove... | entailment |
def addDrizKeywords(self,hdr,versions):
""" Add drizzle parameter keywords to header. """
# Extract some global information for the keywords
_geom = 'User parameters'
_imgnum = 0
for pl in self.parlist:
# Start by building up the keyword prefix based
# ... | Add drizzle parameter keywords to header. | entailment |
def iter_fit_shifts(xy,uv,nclip=3,sigma=3.0):
""" Perform an iterative-fit with 'nclip' iterations
"""
fit = fit_shifts(xy,uv)
if nclip is None: nclip = 0
# define index to initially include all points
for n in range(nclip):
resids = compute_resids(xy,uv,fit)
resids1d = np.sqrt(n... | Perform an iterative-fit with 'nclip' iterations | entailment |
def fit_all(xy,uv,mode='rscale',center=None,verbose=True):
""" Performs an 'rscale' fit between matched lists of pixel positions xy and uv"""
if mode not in ['general', 'shift', 'rscale']:
mode = 'rscale'
if not isinstance(xy,np.ndarray):
# cast input list as numpy ndarray for fitting
... | Performs an 'rscale' fit between matched lists of pixel positions xy and uv | entailment |
def fit_shifts(xy, uv):
""" Performs a simple fit for the shift only between
matched lists of positions 'xy' and 'uv'.
Output: (same as for fit_arrays)
=================================
DEVELOPMENT NOTE:
Checks need to be put in place to verify that
enough ob... | Performs a simple fit for the shift only between
matched lists of positions 'xy' and 'uv'.
Output: (same as for fit_arrays)
=================================
DEVELOPMENT NOTE:
Checks need to be put in place to verify that
enough objects are available for a fit.
... | entailment |
def fit_general(xy, uv):
""" Performs a simple fit for the shift only between
matched lists of positions 'xy' and 'uv'.
Output: (same as for fit_arrays)
=================================
DEVELOPMENT NOTE:
Checks need to be put in place to verify that
enough o... | Performs a simple fit for the shift only between
matched lists of positions 'xy' and 'uv'.
Output: (same as for fit_arrays)
=================================
DEVELOPMENT NOTE:
Checks need to be put in place to verify that
enough objects are available for a fit.
... | entailment |
def fit_arrays(uv, xy):
""" Performs a generalized fit between matched lists of positions
given by the 2 column arrays xy and uv.
This function fits for translation, rotation, and scale changes
between 'xy' and 'uv', allowing for different scales and
orientations for X and Y axes.
... | Performs a generalized fit between matched lists of positions
given by the 2 column arrays xy and uv.
This function fits for translation, rotation, and scale changes
between 'xy' and 'uv', allowing for different scales and
orientations for X and Y axes.
========================... | entailment |
def apply_old_coeffs(xy,coeffs):
""" Apply the offset/shift/rot values from a linear fit
to an array of x,y positions.
"""
_theta = np.deg2rad(coeffs[1])
_mrot = np.zeros(shape=(2,2),dtype=np.float64)
_mrot[0] = (np.cos(_theta),np.sin(_theta))
_mrot[1] = (-np.sin(_theta),np.cos(_theta))
... | Apply the offset/shift/rot values from a linear fit
to an array of x,y positions. | entailment |
def apply_fit(xy,coeffs):
""" Apply the coefficients from a linear fit to
an array of x,y positions.
The coeffs come from the 'coeffs' member of the
'fit_arrays()' output.
"""
x_new = coeffs[0][2] + coeffs[0][0]*xy[:,0] + coeffs[0][1]*xy[:,1]
y_new = coeffs[1][2] + coeffs[1][0]*... | Apply the coefficients from a linear fit to
an array of x,y positions.
The coeffs come from the 'coeffs' member of the
'fit_arrays()' output. | entailment |
def compute_resids(xy,uv,fit):
""" Compute the residuals based on fit and input arrays to the fit
"""
print('FIT coeffs: ',fit['coeffs'])
xn,yn = apply_fit(uv,fit['coeffs'])
resids = xy - np.transpose([xn,yn])
return resids | Compute the residuals based on fit and input arrays to the fit | entailment |
def geomap_rscale(xyin,xyref,center=None):
"""
Set up the products used for computing the fit derived using the code from
lib/geofit.x for the function 'geo_fmagnify()'. Comparisons with results from
geomap (no additional clipping) were made and produced the same results
out to 5 decimal places.
... | Set up the products used for computing the fit derived using the code from
lib/geofit.x for the function 'geo_fmagnify()'. Comparisons with results from
geomap (no additional clipping) were made and produced the same results
out to 5 decimal places.
Output
------
fit: dict
Dictionary co... | entailment |
def AstroDrizzle(input=None, mdriztab=False, editpars=False, configobj=None,
wcsmap=None, **input_dict):
""" AstroDrizzle command-line interface """
# Support input of filenames from command-line without a parameter name
# then copy this into input_dict for merging with TEAL ConfigObj
#... | AstroDrizzle command-line interface | entailment |
def run(configobj, wcsmap=None):
"""
Initial example by Nadia ran MD with configobj EPAR using:
It can be run in one of two ways:
from stsci.tools import teal
1. Passing a config object to teal
teal.teal('drizzlepac/pars/astrodrizzle.cfg')
2. Passing a task name:
... | Initial example by Nadia ran MD with configobj EPAR using:
It can be run in one of two ways:
from stsci.tools import teal
1. Passing a config object to teal
teal.teal('drizzlepac/pars/astrodrizzle.cfg')
2. Passing a task name:
teal.teal('astrodrizzle')
The exa... | entailment |
def _dbg_dump_virtual_outputs(imgObjList):
""" dump some helpful information. strictly for debugging """
global _fidx
tag = 'virtual'
log.info((tag+' ')*7)
for iii in imgObjList:
log.info('-'*80)
log.info(tag+' orig nm: '+iii._original_file_name)
log.info(tag+' names.data... | dump some helpful information. strictly for debugging | entailment |
def getdarkcurrent(self,chip):
"""
Return the dark current for the WFC3 UVIS detector. This value
will be contained within an instrument specific keyword.
Returns
-------
darkcurrent: float
The dark current value with **units of electrons**.
"""
... | Return the dark current for the WFC3 UVIS detector. This value
will be contained within an instrument specific keyword.
Returns
-------
darkcurrent: float
The dark current value with **units of electrons**. | entailment |
def doUnitConversions(self):
"""WF3 IR data come out in electrons, and I imagine the
photometry keywords will be calculated as such, so no image
manipulation needs be done between native and electrons """
# Image information
_handle = fileutil.openImage(self._filename, mode='... | WF3 IR data come out in electrons, and I imagine the
photometry keywords will be calculated as such, so no image
manipulation needs be done between native and electrons | entailment |
def getdarkimg(self,chip):
"""
Return an array representing the dark image for the detector.
Returns
-------
dark: array
Dark image array in the same shape as the input image with **units of cps**
"""
sci_chip = self._image[self.scienceExt,chip]
... | Return an array representing the dark image for the detector.
Returns
-------
dark: array
Dark image array in the same shape as the input image with **units of cps** | entailment |
def getskyimg(self,chip):
"""
Notes
=====
Return an array representing the sky image for the detector. The value
of the sky is what would actually be subtracted from the exposure by
the skysub step.
:units: electrons
"""
sci_chip = self._image[s... | Notes
=====
Return an array representing the sky image for the detector. The value
of the sky is what would actually be subtracted from the exposure by
the skysub step.
:units: electrons | entailment |
def getdarkcurrent(self,extver):
"""
Return the dark current for the ACS detector. This value
will be contained within an instrument specific keyword.
The value in the image header will be converted to units
of electrons.
Returns
-------
darkcurrent: flo... | Return the dark current for the ACS detector. This value
will be contained within an instrument specific keyword.
The value in the image header will be converted to units
of electrons.
Returns
-------
darkcurrent: float
Dark current value for the ACS detecto... | entailment |
def setInstrumentParameters(self,instrpars):
""" Sets the instrument parameters.
"""
pri_header = self._image[0].header
if self._isNotValid (instrpars['gain'], instrpars['gnkeyword']):
instrpars['gnkeyword'] = None
if self._isNotValid (instrpars['rdnoise'], instrpars... | Sets the instrument parameters. | entailment |
def min_med(images, weight_images, readnoise_list, exptime_list,
background_values, weight_masks=None, combine_grow=1,
combine_nsigma1=4, combine_nsigma2=3, fillval=False):
""" Create a median array, rejecting the highest pixel and
computing the lowest valid pixel after mask application.... | Create a median array, rejecting the highest pixel and
computing the lowest valid pixel after mask application.
.. note::
In this version of the mimmed algorithm we assume that the units of
all input data is electons.
Parameters
----------
images : list of numpy.ndarray
Lis... | entailment |
def _sumImages(self,numarrayObjectList):
""" Sum a list of numarray objects. """
if numarrayObjectList in [None, []]:
return None
tsum = np.zeros(numarrayObjectList[0].shape, dtype=numarrayObjectList[0].dtype)
for image in numarrayObjectList:
tsum += image
... | Sum a list of numarray objects. | entailment |
def gaussian1(height, x0, y0, a, b, c):
"""
height - the amplitude of the gaussian
x0, y0, - center of the gaussian
a, b, c - ellipse parameters (coefficients in the quadratic form)
"""
return lambda x, y: height * np.exp(-0.5* (a*(x-x0)**2 + b*(x-x0)*(y-y0) + c*(y-y0)**2)) | height - the amplitude of the gaussian
x0, y0, - center of the gaussian
a, b, c - ellipse parameters (coefficients in the quadratic form) | entailment |
def gausspars(fwhm, nsigma=1.5, ratio=1, theta=0.):
"""
height - the amplitude of the gaussian
x0, y0, - center of the gaussian
fwhm - full width at half maximum of the observation
nsigma - cut the gaussian at nsigma
ratio = ratio of xsigma/ysigma
theta - angle of pos... | height - the amplitude of the gaussian
x0, y0, - center of the gaussian
fwhm - full width at half maximum of the observation
nsigma - cut the gaussian at nsigma
ratio = ratio of xsigma/ysigma
theta - angle of position angle of the major axis measured
counter-clockwise fro... | entailment |
def moments(data,cntr):
"""
Returns (height, x, y, width_x, width_y)
the gaussian parameters of a 2D distribution by calculating its
moments.
"""
total = data.sum()
#X, Y = np.indices(data.shape)
#x = (X*data).sum()/total
#y = (Y*data).sum()/total
x,y = cntr
xi = int(x)
... | Returns (height, x, y, width_x, width_y)
the gaussian parameters of a 2D distribution by calculating its
moments. | entailment |
def apply_nsigma_separation(fitind,fluxes,separation,niter=10):
"""
Remove sources which are within nsigma*fwhm/2 pixels of each other, leaving
only a single valid source in that region.
This algorithm only works for sources which end up sequentially next to each other
based on Y position and remov... | Remove sources which are within nsigma*fwhm/2 pixels of each other, leaving
only a single valid source in that region.
This algorithm only works for sources which end up sequentially next to each other
based on Y position and removes enough duplicates to make the final source list more
managable. It s... | entailment |
def xy_round(data,x0,y0,skymode,ker2d,xsigsq,ysigsq,datamin=None,datamax=None):
""" Compute center of source
Original code from IRAF.noao.digiphot.daofind.apfind ap_xy_round()
"""
nyk,nxk = ker2d.shape
if datamin is None:
datamin = data.min()
if datamax is None:
datamax = data.ma... | Compute center of source
Original code from IRAF.noao.digiphot.daofind.apfind ap_xy_round() | entailment |
def precompute_sharp_round(nxk, nyk, xc, yc):
"""
Pre-computes mask arrays to be used by the 'sharp_round' function
for roundness computations based on two- and four-fold symmetries.
"""
# Create arrays for the two- and four-fold symmetry computations:
s4m = np.ones((nyk,nxk),dtype=np.int16)
... | Pre-computes mask arrays to be used by the 'sharp_round' function
for roundness computations based on two- and four-fold symmetries. | entailment |
def sharp_round(data, density, kskip, xc, yc, s2m, s4m, nxk, nyk,
datamin, datamax):
"""
sharp_round -- Compute first estimate of the roundness and sharpness of the
detected objects.
A Python translation of the AP_SHARP_ROUND IRAF/DAOFIND function.
"""
# Compute the first estim... | sharp_round -- Compute first estimate of the roundness and sharpness of the
detected objects.
A Python translation of the AP_SHARP_ROUND IRAF/DAOFIND function. | entailment |
def roundness(im):
"""
from astropy.io import fits as pyfits
data=pyfits.getdata('j94f05bgq_flt.fits',ext=1)
star0=data[403:412,423:432]
star=data[396:432,3522:3558]
In [53]: findobj.roundness(star0)
Out[53]: 0.99401955054989544
In [54]: findobj.roundness(star)
Out[54]: 0.83091919980... | from astropy.io import fits as pyfits
data=pyfits.getdata('j94f05bgq_flt.fits',ext=1)
star0=data[403:412,423:432]
star=data[396:432,3522:3558]
In [53]: findobj.roundness(star0)
Out[53]: 0.99401955054989544
In [54]: findobj.roundness(star)
Out[54]: 0.83091919980660645 | entailment |
def immoments(im, p,q):
x = list(range(im.shape[1]))
y = list(range(im.shape[0]))
#coord=np.array([x.flatten(),y.flatten()]).T
"""
moment = 0
momentx = 0
for i in x.flatten():
moment+=momentx
sumx=0
for j in y.flatten():
sumx+=i**0*j**0*star0[i,j]
"""
... | moment = 0
momentx = 0
for i in x.flatten():
moment+=momentx
sumx=0
for j in y.flatten():
sumx+=i**0*j**0*star0[i,j] | entailment |
def centroid(im):
"""
Computes the centroid of an image using the image moments:
centroid = {m10/m00, m01/m00}
These calls point to Python version of moments function
m00 = immoments(im,0,0)
m10 = immoments(im, 1,0)
m01 = immoments(im,0,1)
"""
# These calls point to Python version... | Computes the centroid of an image using the image moments:
centroid = {m10/m00, m01/m00}
These calls point to Python version of moments function
m00 = immoments(im,0,0)
m10 = immoments(im, 1,0)
m01 = immoments(im,0,1) | entailment |
def getMdriztabParameters(files):
""" Gets entry in MDRIZTAB where task parameters live.
This method returns a record array mapping the selected
row.
"""
# Get the MDRIZTAB table file name from the primary header.
# It is gotten from the first file in the input list. No
# consistenc... | Gets entry in MDRIZTAB where task parameters live.
This method returns a record array mapping the selected
row. | entailment |
def _interpretMdriztabPars(rec):
"""
Collect task parameters from the MDRIZTAB record and
update the master parameters list with those values
Note that parameters read from the MDRIZTAB record must
be cleaned up in a similar way that parameters read
from the user interface are.
"""
tabd... | Collect task parameters from the MDRIZTAB record and
update the master parameters list with those values
Note that parameters read from the MDRIZTAB record must
be cleaned up in a similar way that parameters read
from the user interface are. | entailment |
def run(configObj,wcsmap=None):
""" Interpret parameters from TEAL/configObj interface as set interactively
by the user and build the new WCS instance
"""
distortion_pars = configObj['Distortion Model']
outwcs = build(configObj['outwcs'], configObj['wcsname'],
configObj['refimage']... | Interpret parameters from TEAL/configObj interface as set interactively
by the user and build the new WCS instance | entailment |
def build(outname, wcsname, refimage, undistort=False,
applycoeffs=False, coeffsfile=None, **wcspars):
""" Core functionality to create a WCS instance from a reference image WCS,
user supplied parameters or user adjusted reference WCS.
The distortion information can either be read in as pa... | Core functionality to create a WCS instance from a reference image WCS,
user supplied parameters or user adjusted reference WCS.
The distortion information can either be read in as part of the reference
image WCS or given in 'coeffsfile'.
Parameters
----------
outname ... | entailment |
def create_WCSname(wcsname):
""" Verify that a valid WCSNAME has been provided, and if not, create a
default WCSNAME based on current date.
"""
if util.is_blank(wcsname):
ptime = fileutil.getDate()
wcsname = "User_"+ptime
return wcsname | Verify that a valid WCSNAME has been provided, and if not, create a
default WCSNAME based on current date. | entailment |
def convert_user_pars(wcspars):
""" Convert the parameters provided by the configObj into the corresponding
parameters from an HSTWCS object
"""
default_pars = default_user_wcs.copy()
for kw in user_hstwcs_pars:
default_pars[user_hstwcs_pars[kw]] = wcspars[kw]
return default_pars | Convert the parameters provided by the configObj into the corresponding
parameters from an HSTWCS object | entailment |
def mergewcs(outwcs, customwcs, wcspars):
""" Merge the WCS keywords from user specified values into a full HSTWCS object
This function will essentially follow the same algorithm as used by
updatehdr only it will use direct calls to updatewcs.Makewcs methods
instead of using 'updatewcs' as a... | Merge the WCS keywords from user specified values into a full HSTWCS object
This function will essentially follow the same algorithm as used by
updatehdr only it will use direct calls to updatewcs.Makewcs methods
instead of using 'updatewcs' as a whole | entailment |
def add_model(refwcs, newcoeffs):
""" Add (new?) distortion model to existing HSTWCS object
"""
# Update refwcs with distortion model
for kw in model_attrs:
if newcoeffs.__dict__[key] is not None:
refwcs.__dict__[key] = newcoeffs.__dict__[key] | Add (new?) distortion model to existing HSTWCS object | entailment |
def apply_model(refwcs):
""" Apply distortion model to WCS, including modifying
CD with linear distortion terms
"""
# apply distortion model to CD matrix
if 'ocx10' in refwcs.__dict__ and refwcs.ocx10 is not None:
linmat = np.array([[refwcs.ocx11,refwcs.ocx10],[refwcs.ocy11,refwcs.ocy10... | Apply distortion model to WCS, including modifying
CD with linear distortion terms | entailment |
def replace_model(refwcs, newcoeffs):
""" Replace the distortion model in a current WCS with a new model
Start by creating linear WCS, then run
"""
print('WARNING:')
print(' Replacing existing distortion model with one')
print(' not necessarily matched to the observation!')
# creat... | Replace the distortion model in a current WCS with a new model
Start by creating linear WCS, then run | entailment |
def undistortWCS(refwcs):
""" Generate an undistorted HSTWCS from an HSTWCS object with a distortion model
"""
wcslin = stwcs.distortion.utils.output_wcs([refwcs])
outwcs = stwcs.wcsutil.HSTWCS()
outwcs.wcs = wcslin.wcs
outwcs.wcs.set()
outwcs.setPscale()
outwcs.setOrient()
outwcs.s... | Generate an undistorted HSTWCS from an HSTWCS object with a distortion model | entailment |
def generate_headerlet(outwcs,template,wcsname,outname=None):
""" Create a headerlet based on the updated HSTWCS object
This function uses 'template' as the basis for the headerlet.
This file can either be the original wcspars['refimage'] or
wcspars['coeffsfile'], in this order of preferenc... | Create a headerlet based on the updated HSTWCS object
This function uses 'template' as the basis for the headerlet.
This file can either be the original wcspars['refimage'] or
wcspars['coeffsfile'], in this order of preference.
If 'template' is None, then a simple Headerlet will be
... | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.