API¶
obiwan.runbrick module¶
obiwan.kenobi module¶
Classes to extend legacypipe.
-
class
obiwan.kenobi.BaseSimImage¶ Bases:
objectDumb class that extends
get_tractor_image()for future multiple inheritance.-
get_zpscale()¶ Return zpscale for image units to nanomaggies conversion.
-
-
class
obiwan.kenobi.BaseSimStamp(tim, **attrs)¶ Bases:
objectDraw model galaxies for a single image.
Parent class to be inherited from to build different galaxy models.
-
tim¶ Tractor image.
- Type
tractor.Image
-
band¶ Image band.
- Type
string
-
xcen¶ x center of the source in subimage pixel coordinates.
- Type
float
-
ycen¶ y center of the source in subimage pixel coordinates.
- Type
float
-
attrs¶ Other attributes.
- Type
dict
- Parameters
tim (tractor.Image) – Current tractor.Image.
attrs (dict) – Other attributes useful to define patches (e.g.
nx,ny).
-
-
class
obiwan.kenobi.BaseSimSurvey(*args, simcat=None, sim_stamp='tractor', add_sim_noise=False, image_eq_model=False, seed=0, kwargs_file=None, **kwargs)¶ Bases:
objectDumb class with Obiwan attributes for future multiple inheritance.
-
simcat¶ See below.
- Type
SimCatalog
-
sim_stamp¶ See below.
- Type
string
-
add_sim_noise¶ See below.
- Type
string
-
image_eq_model¶ See below.
- Type
bool
-
kwargs_file¶ See below.
- Type
dict
-
rng¶ Random state, from
seed`.
-
image_typemap¶ Mapping (camera,class) used by
legacypipe.survey.LegacySurveyData.- Type
dict
-
survey_dir¶ Directory containing input imaging data.
- Type
string
-
output_dir¶ Directory containing output catalogs.
- Type
string
kwargs are to be passed on to
legacypipe.survey.LegacySurveyData-inherited classes, other arguments are specific toBaseSimSurvey. Onlysurvey_dirmust be specified to obtain bricks throughget_brick_by_name().- Parameters
simcat (SimCatalog, default=None) – Simulated source catalog for a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate objects, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise from the simulated source to the image. Choices: [‘gaussian’,’poisson’].
image_eq_model (bool, default=False) – Wherever add a simulated source, replace both image and inverse variance of the image with that of the simulated source only.
seed (int, default=0) – For random number generators.
kwargs_file (dict, default=None) – Extra arguments to file paths (e.g.
get_randoms_id.keys()).kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
-
find_file(filetype, brick=None, output=False, stage=None, **kwargs)¶ Return the file name of a Legacy Survey file.
- Parameters
filetype (string) – Type of file to find, including: - ‘randoms’: input random catalogues - ‘pickle’: pickle files - ‘checkpoint’: checkpoint files - ‘log’ : log files - ‘ps’ : ps (resources time series) catalogs - ‘tractor’: Tractor catalogs - ‘depth’: PSF depth maps - ‘galdepth’: canonical galaxy depth maps - ‘nexp’: number-of-exposure maps.
brick (string, defaut=None) – Brick name.
output (bool, default=False) – Whether we are about to write this file; will use
output_diras the base directory rather thansurvey_dir.stage (string, default=None) – Stage, only used if
filetype == 'pickle'.kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.find_file().
- Returns
fn – Path to the specified file (whether or not it exists).
- Return type
string
-
-
class
obiwan.kenobi.BokSimImage(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimImage,legacypipe.bok.Extend
BaseSimImagewithlegacypipe.bok.BokImage.Note
Image unit is electrons/second (x exptime -> electrons).
-
get_nano2e(*args, **kwargs)¶ Return nanomaggies to electron counts conversion.
-
-
class
obiwan.kenobi.CosmosSim(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimSurvey,legacypipe.runcosmos.Extend
BaseSimSurveywith a filter for cosmos CCDs.Call with BaseSimSurvey arguments plus additional CosmosSurvey argument
subset.kwargs are to be passed on to
legacypipe.survey.LegacySurveyData-inherited classes, other arguments are specific toBaseSimSurvey. Onlysurvey_dirmust be specified to obtain bricks throughget_brick_by_name().- Parameters
simcat (SimCatalog, default=None) – Simulated source catalog for a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate objects, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise from the simulated source to the image. Choices: [‘gaussian’,’poisson’].
image_eq_model (bool, default=False) – Wherever add a simulated source, replace both image and inverse variance of the image with that of the simulated source only.
seed (int, default=0) – For random number generators.
kwargs_file (dict, default=None) – Extra arguments to file paths (e.g.
get_randoms_id.keys()).kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
-
class
obiwan.kenobi.DecamSim(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimSurvey,legacypipe.runs.Extend
BaseSimSurveywith a filter for DECam CCDs.kwargs are to be passed on to
legacypipe.survey.LegacySurveyData-inherited classes, other arguments are specific toBaseSimSurvey. Onlysurvey_dirmust be specified to obtain bricks throughget_brick_by_name().- Parameters
simcat (SimCatalog, default=None) – Simulated source catalog for a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate objects, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise from the simulated source to the image. Choices: [‘gaussian’,’poisson’].
image_eq_model (bool, default=False) – Wherever add a simulated source, replace both image and inverse variance of the image with that of the simulated source only.
seed (int, default=0) – For random number generators.
kwargs_file (dict, default=None) – Extra arguments to file paths (e.g.
get_randoms_id.keys()).kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
-
class
obiwan.kenobi.DecamSimImage(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimImage,legacypipe.decam.Extend
BaseSimImagewithlegacypipe.decam.DecamImage.Note
Image unit is ADU (x gain -> electrons).
References
http://ast.noao.edu/sites/default/files/NOAO_DHB_v2.2.pdf
-
get_gain(tim, x, y)¶ Return gain at the one-indexed pixel position
x,yin thetimsubimage.- Parameters
tim (tractor.Image) – Current
tractor.Image.x (int, array-like) – Pixel one-indexed x-position in the
timsubimage, 1-dim.y (int, array-like) – Pixel one-indexed y-position in the
timsubimage, 1-dim.
- Returns
gain – Gain (ADU x gain -> electrons).
- Return type
float, array-like
-
get_nano2e(*args, **kwargs)¶ Return nanomaggies to electron counts conversion.
-
-
class
obiwan.kenobi.DecamSimImagePlusNoise(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimImage,legacypipe.runcosmos.Extend
BaseSimImagewithDecamImagePlusNoise.Note
Image unit is ADU (x gain -> electrons).
Warning
Conversion should be checked further!
-
get_gain(*args, **kwargs)¶ Return gain.
-
get_nano2e(*args, **kwargs)¶ Return nanomaggies to electron counts conversion.
-
-
class
obiwan.kenobi.GSImage(*args: Any, **kwargs: Any)¶ Bases:
galsim.Extend
galsim.Image, with other__setitem__options.
-
class
obiwan.kenobi.GalSimStamp(tim, **attrs)¶ Bases:
obiwan.kenobi.BaseSimStampExtend
BaseSimStampwith generation of galsim objects.-
scale¶ Pixel scale.
- Type
float
-
offsetint¶ Integer position of object in subimage.
- Type
galsim.PositionI
-
offsetfrac¶ Fractional position of object in subimage.
- Type
galsim.PositionD
- Parameters
tim (tractor.Image) – Current tractor.Image.
attrs (dict) – Other attributes useful to define patches (e.g.
nx,ny).
-
draw(obj)¶ Return a
GSImagewithobjin the center.If either
obj.sersicorobj.shape_ris 0, a point source is drawn. Else a Sersic profile is used.- Parameters
obj (SimCatalog row) – An object with attributes
ra,dec,sersic,shape_r,shape_e1,shape_e2,'flux_'+self.band.- Returns
gim – Image with
obj.- Return type
-
set_local(ra, dec)¶ Extend
BaseSimStamp.set_local()by setting pixelscale,psfand object integer and fractional positionsoffsetintandoffsetfrac.- Parameters
ra (float) – Right ascension (degree).
dec (float) – Declination (degree).
-
-
class
obiwan.kenobi.LegacySurveySim(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimSurvey,legacypipe.survey.Extend
BaseSimSurveywithlegacypipe.survey.LegacySurveyData.kwargs are to be passed on to
legacypipe.survey.LegacySurveyData-inherited classes, other arguments are specific toBaseSimSurvey. Onlysurvey_dirmust be specified to obtain bricks throughget_brick_by_name().- Parameters
simcat (SimCatalog, default=None) – Simulated source catalog for a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate objects, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise from the simulated source to the image. Choices: [‘gaussian’,’poisson’].
image_eq_model (bool, default=False) – Wherever add a simulated source, replace both image and inverse variance of the image with that of the simulated source only.
seed (int, default=0) – For random number generators.
kwargs_file (dict, default=None) – Extra arguments to file paths (e.g.
get_randoms_id.keys()).kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
-
class
obiwan.kenobi.MegaPrimeSimImage(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimImage,legacypipe.cfht.Extend
BaseSimImagewithlegacypipe.cfht.MegaPrimeImage.Note
Image unit is ADU (x gain -> electrons).
References
https://www.cfht.hawaii.edu/Instruments/Imaging/MegaPrime/rawdata.html#P2
-
get_gain(tim, x, y)¶ Return gain at the one-indexed pixel position
x,yin thetimsubimage.- Parameters
tim (tractor.Image) – Current tractor.Image.
x (int, array-like) – Pixel one-indexed x-position in the
timsubimage, 1-dim.y (int, array-like) – Pixel one-indexed y-position in the
timsubimage, 1-dim.
- Returns
gain – Gain (ADU x gain -> electrons).
- Return type
float, array-like
-
get_nano2e(*args, **kwargs)¶ Return nanomaggies to electron counts conversion.
-
-
class
obiwan.kenobi.MosaicSimImage(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimImage,legacypipe.mosaic.Extend
BaseSimImagewithlegacypipe.mosaic.MosaicImage.Note
Image unit is electrons/second (x exptime -> electrons).
-
get_nano2e(*args, **kwargs)¶ Return nanomaggies to electron counts conversion.
-
-
class
obiwan.kenobi.NinetyPrimeMosaicSim(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimSurvey,legacypipe.runs.Extend
BaseSimSurveywith a filter for mosaic or 90prime CCDs.kwargs are to be passed on to
legacypipe.survey.LegacySurveyData-inherited classes, other arguments are specific toBaseSimSurvey. Onlysurvey_dirmust be specified to obtain bricks throughget_brick_by_name().- Parameters
simcat (SimCatalog, default=None) – Simulated source catalog for a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate objects, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise from the simulated source to the image. Choices: [‘gaussian’,’poisson’].
image_eq_model (bool, default=False) – Wherever add a simulated source, replace both image and inverse variance of the image with that of the simulated source only.
seed (int, default=0) – For random number generators.
kwargs_file (dict, default=None) – Extra arguments to file paths (e.g.
get_randoms_id.keys()).kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
-
class
obiwan.kenobi.PtfSimImage(*args: Any, **kwargs: Any)¶ Bases:
obiwan.kenobi.BaseSimImage,legacypipe.ptf.Extend
BaseSimImagewithlegacypipe.ptf.PtfImage.Note
Image unit is ADU (x gain -> electrons).
-
get_gain(tim, *args, **kwargs)¶ Return gain.
-
get_nano2e(*args, **kwargs)¶ Return nanomaggies to electron counts conversion.
-
-
class
obiwan.kenobi.TractorSimStamp(tim, **attrs)¶ Bases:
obiwan.kenobi.BaseSimStampExtend
BaseSimStampwith generation of Tractor objects.-
slcx¶ x slice of the subimage where object will be generated.
- Type
tuple
-
slcy¶ y slice.
- Type
tuple
- Parameters
tim (tractor.Image) – Current tractor.Image.
attrs (dict) – Other attributes useful to define patches (e.g.
nx,ny).
-
draw(obj)¶ Return a
GSImagewithobjin the center.If either
obj.sersicorobj.shape_ris 0, a point source is drawn. Else a Sersic profile is used.- Parameters
obj (SimCatalog row) – An object with attributes
ra,dec,sersic,shape_r,shape_e1,shape_e2,'flux_%s' % self.band.- Returns
gim – Image with
objif the stamp overlaps the tim, else None.- Return type
GSImage, None
-
-
obiwan.kenobi.find_file(base_dir=None, filetype=None, brickname=None, source='obiwan', **kwargs)¶ Return file name.
Shortcut to
LegacySurveySim.find_file().- base_dirstring, default=None
Obiwan (if
source == 'obiwan') or legacypipe (ifsource == 'legacypipe') root file directory.- filetypestring, default=None
Type of file to find.
- bricknamestring, default=None
Brick name.
- sourcestring, default=’obiwan’
If ‘obiwan’, return an Obiwan output file name, else a legacypipe file name.
- kwargsdict
Other arguments to file paths (e.g.
get_randoms_id.keys()).
-
obiwan.kenobi.find_legacypipe_file(survey_dir, filetype, brickname=None, **kwargs)¶ Return legacypipe file name.
- survey_dirstring
Survey directory.
- filetypestring
Type of file to find.
- bricknamestring
Brick name.
- kwargsdict
Other arguments to file paths (e.g.
get_randoms_id.keys()).
-
obiwan.kenobi.find_obiwan_file(output_dir, filetype, brickname=None, **kwargs)¶ Return Obiwan output file name.
- output_dirstring
Obiwan output directory.
- filetypestring
Type of file to find.
- bricknamestring
Brick name.
- kwargsdict
Other arguments to file paths (e.g.
get_randoms_id.keys()).
-
obiwan.kenobi.get_git_version(dirnm=None)¶ Run ‘git describe’ in the current directory (or given dir) and return the result as a string.
- Parameters
dirnm (string, default=None) – If not
None, ‘cd’ to the given directory before running ‘git describe’.- Returns
version – Git version.
- Return type
string
Notes
Taken from https://github.com/legacysurvey/legacypipe/blob/master/py/legacypipe/survey.py
-
class
obiwan.kenobi.get_randoms_id(**kwargs)¶ Bases:
objectHandle identifier related to input random catalog: file id, row start, skip id.
Return string corresponding to randoms id kwargs.
-
classmethod
as_dict(**kwargs)¶ Return randoms id kwargs corresponding to kwargs.
-
classmethod
as_list(**kwargs)¶ Return list corresponding to randoms id kwargs.
-
classmethod
default()¶ Return default values.
-
classmethod
keys()¶ Return keys.
-
classmethod
kwargs_match_template()¶ Return kwargs to reconstruct match template.
-
classmethod
match(string)¶ Match randoms id in
stringand return randoms id kwargs.
-
classmethod
match_template()¶ Return match template.
-
classmethod
template()¶ Return string template.
-
classmethod
-
obiwan.kenobi.get_survey(name, **kwargs)¶ Return an instance of the
BaseSimSurvey-inherited class given by name.See
obiwan.kenobi.runsdictionary.
-
obiwan.kenobi.get_version()¶ Return
get_git_version()if not empty, elseobiwan.__version__.