API¶
legacysim.survey module¶
Classes to extend legacypipe.survey.
- class legacysim.survey.BaseSimSurvey(*args, injected=None, sim_stamp='tractor', add_sim_noise=False, image_eq_model=False, kwargs_simid=None, **kwargs)¶
Bases:
objectDumb class with legacysim attributes for future multiple inheritance.
- injected¶
See below.
- Type
- sim_stamp¶
See below.
- Type
string
- add_sim_noise¶
See below.
- Type
string
- image_eq_model¶
See below.
- Type
bool
- kwargs_simid¶
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
injected (SimCatalog, default=None) – Catalog of sources to inject in a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate sources, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise related to 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.
kwargs_simid (dict, default=None) –
get_sim_iddictionary with keysget_sim_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: - ‘injected’: injected sources - ‘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 legacysim.survey.CosmosSim(*args: Any, **kwargs: Any)¶
Bases:
legacysim.survey.BaseSimSurvey,legacypipe.runcosmos.CosmosSurveyExtend
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
injected (SimCatalog, default=None) – Catalog of sources to inject in a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate sources, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise related to 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.
kwargs_simid (dict, default=None) –
get_sim_iddictionary with keysget_sim_id.keys().kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
- class legacysim.survey.DecamSim(*args: Any, **kwargs: Any)¶
Bases:
legacysim.survey.BaseSimSurvey,legacypipe.runs.DecamSurveyExtend
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
injected (SimCatalog, default=None) – Catalog of sources to inject in a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate sources, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise related to 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.
kwargs_simid (dict, default=None) –
get_sim_iddictionary with keysget_sim_id.keys().kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
- class legacysim.survey.LegacySurveySim(*args: Any, **kwargs: Any)¶
Bases:
legacysim.survey.BaseSimSurvey,legacypipe.survey.LegacySurveyDataExtend
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
injected (SimCatalog, default=None) – Catalog of sources to inject in a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate sources, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise related to 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.
kwargs_simid (dict, default=None) –
get_sim_iddictionary with keysget_sim_id.keys().kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
- class legacysim.survey.NinetyPrimeMosaicSim(*args: Any, **kwargs: Any)¶
Bases:
legacysim.survey.BaseSimSurvey,legacypipe.runs.NinetyPrimeMosaicExtend
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
injected (SimCatalog, default=None) – Catalog of sources to inject in a given brick (not CCD).
sim_stamp (string, default='tractor') – Method to simulate sources, either ‘tractor’ (
TractorSimStamp) or ‘galsim’ (GalSimStamp).add_sim_noise (string, default=False) – Add noise related to 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.
kwargs_simid (dict, default=None) –
get_sim_iddictionary with keysget_sim_id.keys().kwargs (dict) – Arguments for
legacypipe.survey.LegacySurveyData.
- legacysim.survey.find_file(base_dir=None, filetype=None, brickname=None, source='legacysim', **kwargs)¶
Return file name.
Shortcut to
LegacySurveySim.find_file().- base_dirstring, default=None
legacysim (if
source == 'legacysim') or legacypipe (ifsource == 'legacypipe') root file directory.- filetypestring, default=None
Type of file to find.
- bricknamestring, default=None
Brick name.
- sourcestring, default=’legacysim’
If ‘legacysim’, return an legacysim output file name, else a legacypipe file name.
- kwargsdict
Other arguments to file paths (e.g.
get_sim_id.keys()).
- legacysim.survey.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_sim_id.keys()).
- legacysim.survey.find_legacysim_file(output_dir, filetype, brickname=None, **kwargs)¶
Return legacysim output file name.
- output_dirstring
legacysim output directory.
- filetypestring
Type of file to find.
- bricknamestring
Brick name.
- kwargsdict
Other arguments to file paths (e.g.
get_sim_id.keys()).
- legacysim.survey.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 legacysim.survey.get_sim_id(**kwargs)¶
Bases:
objectHandle identifier related to simulation: file id, row start, skip id.
Return string corresponding to sim id kwargs.
- classmethod as_dict(**kwargs)¶
Return sim id kwargs corresponding to kwargs.
- classmethod as_list(**kwargs)¶
Return list corresponding to sim 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 sim id in
stringand return sim id kwargs.
- classmethod match_template()¶
Return match template.
- classmethod template()¶
Return string template.
- legacysim.survey.get_survey(name, **kwargs)¶
Return an instance of the
BaseSimSurvey-inherited class given by name.See
legacysim.survey.runsdictionary.
- legacysim.survey.get_version()¶
Return
get_git_version()if not empty, elselegacysim.__version__.
legacysim.image module¶
Classes to extend legacypipe.image.
- class legacysim.image.BaseSimImage¶
Bases:
objectDumb class that extends
legacypipe.image.get_tractor_image()for future multiple inheritance.- get_zpscale()¶
Return zpscale for image units to nanomaggies conversion.
- class legacysim.image.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 legacysim.image.BokSimImage(*args: Any, **kwargs: Any)¶
Bases:
legacysim.image.BaseSimImage,legacypipe.bok.BokImageExtend
BaseSimImagewithlegacypipe.bok.BokImage.Note
Image unit is electrons/second (x exptime -> electrons).
- get_nano2e(*args, **kwargs)¶
Return nanomaggies to electron counts conversion.
- class legacysim.image.DecamSimImage(*args: Any, **kwargs: Any)¶
Bases:
legacysim.image.BaseSimImage,legacypipe.decam.DecamImageExtend
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 legacysim.image.DecamSimImagePlusNoise(*args: Any, **kwargs: Any)¶
Bases:
legacysim.image.BaseSimImage,legacypipe.runcosmos.DecamImagePlusNoiseExtend
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 legacysim.image.GSImage(*args: Any, **kwargs: Any)¶
Bases:
galsim.ImageExtend
galsim.Image, with other__setitem__options.
- class legacysim.image.GalSimStamp(tim, **attrs)¶
Bases:
legacysim.image.BaseSimStampExtend
BaseSimStampwith generation of galsim source stamps.- 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 legacysim.image.MegaPrimeSimImage(*args: Any, **kwargs: Any)¶
Bases:
legacysim.image.BaseSimImage,legacypipe.cfht.MegaPrimeImageExtend
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 legacysim.image.MosaicSimImage(*args: Any, **kwargs: Any)¶
Bases:
legacysim.image.BaseSimImage,legacypipe.mosaic.MosaicImageExtend
BaseSimImagewithlegacypipe.mosaic.MosaicImage.Note
Image unit is electrons/second (x exptime -> electrons).
- get_nano2e(*args, **kwargs)¶
Return nanomaggies to electron counts conversion.
- class legacysim.image.PtfSimImage(*args: Any, **kwargs: Any)¶
Bases:
legacysim.image.BaseSimImage,legacypipe.ptf.PtfImageExtend
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 legacysim.image.TractorSimStamp(tim, **attrs)¶
Bases:
legacysim.image.BaseSimStampExtend
BaseSimStampwith generation of Tractor source stamps.- 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
legacysim.catalog module¶
Convenient classes to handle catalogs, bricks and runs.
- class legacysim.catalog.BaseCatalog(*args: Any, **kwargs: Any)¶
Bases:
astrometry.util.fits.tabledataExtend
tabledata, with convenient methods.- _columns¶
Catalog columns, including internals (starting with _). Without internals:
fields.- Type
list
Call
astrometry.util.fits.fits_table().For an empty catalog, one can provide size or length, to define
len(), used in methods to buildnumpyarrays (e.g.zeros()). Otherwise,len()is set when the first column is added.- copy(fields=None)¶
Return a (deep) copy, keeping columns
fields.- Parameters
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields.- Returns
new – Copy.
- Return type
Note
Contrary to
astrometry.util.fits.tabledata, all internal (starting with ‘_’) values are (deep) copied.
- delete_columns(*fields)¶
Delete columns
fields.
- property fields¶
Return
fields = self.get_columns(internal=False).
- fill(other, index_self=None, index_other=None, fields_other=None, fill_nan=True)¶
Fill (or create) columns with those of
othercatalog.If a column of name
fieldalready exists inself(with a shape compatible with that ofother), the values with indicesindex_selfare replaced by those ofotherwith indicesindex_other. Else, a new column is added toself, with default value given bynumpy.zeros()(ornumpy.naniffill_nan == True). Again, the values with indicesindex_selfare replaced by those ofotherwith indicesindex_other.- Parameters
other (BaseCatalog) – Catalog to be merged to
self.index_self (slice, ndarray, string, default=None) – Indices (or bool mask) of
selfto fill withother. IfNone, all indices ofselfare considered. If before,other[index_other]rows are added at the beginning ofself. If after,other[index_other]rows are added at the end ofself.index_other (slice, ndarray, default=None) – Indices (or bool mask) of
otherto fillself. IfNone, all indices ofotherare considered.fields_other (list, default=None) – Fields of
otherto be added toself. IfNone, all fields of other are considered.fill_nan (bool, default=True) – If
True, default value for added column isnumpy.naninstead ofnumpy.zeros().
- classmethod from_dict(d)¶
Construct catalog from dictionary of (field, column).
- index()¶
Return zero-starting index.
- isin(other, fields=None)¶
Return mask selecting rows that are in
otherforfields.- Parameters
other (BaseCatalog) – Other catalog.
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields.
- Returns
mask – Mask.
- Return type
bool ndarray
- keep_columns(*fields)¶
Keep only columns
fields.
- remove_duplicates(fields=None, copy=False)¶
Remove duplicate rows for
fields.Returned catalog has the same fields as
self.- Parameters
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields.copy (bool, default=False) – Return copy?
- Returns
se;f – Catalog without duplicate rows.
- Return type
- repeat(repeats, copy=True)¶
Apply
numpy.repeat()to every column.- Parameters
repeats (int) – Number of repeats.
copy (bool, default=False) – Return copy?
- Returns
new – Repeated catalog.
- Return type
- property size¶
Return
len().
- tile(repeats, copy=True)¶
Apply
numpy.tile()to every column.- Parameters
repeats (int) – Number of repeats.
copy (bool, default=False) – Return copy?
- Returns
new – Tiled catalog.
- Return type
- to_ndarray(fields=None)¶
Return
numpy.ndarrayrepresentation for columnsfields.- Parameters
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields.- Returns
array –
numpy.ndarrayinstance.- Return type
ndarray
- to_recarray(fields=None)¶
Return
numpy.recarrayrepresentation for columnsfields.- Parameters
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields.- Returns
array –
numpy.recarrayinstance.- Return type
recarray
- uniqid(fields=None)¶
Return unique id for
fields.- Parameters
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields.- Returns
array –
numpy.ndarraystrings with shapesize.- Return type
ndarray
- unique(fields=None, sort_index=False, return_unique=True, **kwargs)¶
Return catalog with unique rows for columns
fields.- Parameters
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields.sort_index (bool, default=False) – Sort by increasing index.
return_unique (bool, default=True) – Return catalog with unique rows for columns
fields.kwargs (dict) – Other arguments for
numpy.unique().
- Returns
unique – If
return_unique == True, return catalog with unique rows. For other values seenumpy.unique().- Return type
- writeto(fn, *args, **kwargs)¶
Write to
fn.
- class legacysim.catalog.BrickCatalog(*args: Any, **kwargs: Any)¶
Bases:
legacysim.catalog.BaseCatalogExtend
BaseCatalogwith convenient methods for bricks.- _rowmax, _colmax, _ncols
internals to grep brick from ra, dec (see
get_by_radec()).- Type
int, int, ndarray
- hash¶
Hash table to grep brick from ra, dec.
- Type
ndarray
- columns¶
brickname,brickid, etc.- Type
ndarray
Load bricks.
- Parameters
survey (LegacySurveyData, string, default=None) –
survey_dirorsurvey. IfNone, constructBrickCatalogfromdesiutil.brick.Bricks.
- get_area(total=False)¶
Return area of individual bricks.
Calls
utils.get_radecbox_area().- Parameters
total (bool, default=False) – If
True, returns total area.- Returns
area – Area (degree^2).
- Return type
float, ndarray
- get_by_name(brickname)¶
Return bricks with name
brickname.- Parameters
brickname (string, array-like) – If string, return a single-element
BrickCatalog, else aBrickCatalogwith definedsize.- Returns
bricks –
selfcut tobrickname.- Return type
- get_by_radec(ra, dec)¶
Return bricks containing
ra,dec.- Parameters
ra (float, array-like) – Right ascension (degree).
dec (float, array-like) – Declination (degree).
- Returns
bricks –
selfcut to bricks containingra,dec.- Return type
- get_radecbox(total=False)¶
Return ra, dec box (ramin, ramax, decmin, decmax) of individual bricks.
- Parameters
total (bool, default=False) – If
True, returns the ra, dec box enclosing all bricks.- Returns
(ramin, ramax, decmin, decmax) – ra, dec box.
- Return type
tuple of float, ndarray
- get_xy_from_radec(ra, dec, brickname=None)¶
Returns brick
bx,bygivenra,dec.- Parameters
ra (float, array-like) – Right ascension (degree).
dec (float, array-like) – Declination (degree).
brickname (string, array-like, default=None) – Brick name. If array-like, should be of the same length as
ra,dec. IfNone, will query the correctbricknamegivenra,dec.
- Returns
bx (float, ndarray) – Brick x coordinate.
by (float, ndarray) – Brick y coordinate.
- static read_list(bricklist, unique=True)¶
Read brick list and return list of (unique) brick names.
- Parameters
bricklist (list, string) – List of strings (or one string) corresponding either brick names or ASCII files containing a column of brick names.
unique (bool, default=True) – Return unique brick names?
- Returns
bricknames – List of (unique) brick names.
- Return type
list
- write_list(fn)¶
Write brick names to
fn.- Parameters
fn (string) – Path to brick list.
- class legacysim.catalog.ListStages(args=None)¶
Bases:
collections.UserListHandle list of unique stages.
argsmust be a list of stages.- append(*args, **kwargs)¶
Append stages, return current index.
- index(stages)¶
Return index of stages if in
self, else -1.
- match(other)¶
Match list stages.
- Parameters
other (Stages) – Other stages.
- Returns
istages1 (list) –
- The list of indices in
selfmatchingother, such that:: - for iother,iself in enumerate(istages1):
# iself is the index in self # iother is the corresponding index in other
- The list of indices in
istages2 (list) – The list of indices in
othermatchingself.
- without_versions()¶
Return copy with empty versions and its list of indices matching
self,- Returns
new (ListStages) – Versions are all empty.
istages (list) –
List of indices, such that:
for iself,inew in enumerate(istages): # iself is the index in self # inew is the corresponding index in new
- class legacysim.catalog.RunCatalog(*args: Any, **kwargs: Any)¶
Bases:
legacysim.catalog.BaseCatalogExtend
BaseCatalogwith convenient methods for run (defined by brick x sim id x stages id) lists.Useful to schedule jobs and navigate through the legacysim or legacypipe file structure.
- _list_stages¶
List of stages corresponding to indices in column
stagesid.- Type
Initialize
RunCatalogfrom array or file name.- append(other)¶
Append
otherrows toself, taking care to update the columnstagesid.
- append_stages(*args, **kwargs)¶
Shortcut for
self._list_stages.append(*args,**kwargs).
- check()¶
Raise
ValueErrorif there are rows with same (brickname x sim id) but differentstagesid.
- count_runs(*args, **kwargs)¶
Return the number of runs in input catalog
cat(seeiter_mask()).
- property fields¶
Return fields.
- classmethod from_brick_sim_id(bricknames=None, kwargs_simids=None, stages=None)¶
Initialize
RunCatalogfrom a list of bricks, sim ids and stages id.- Parameters
bricknames (list, string, default=None) – Single brick name or list of brick names.
kwargs_simids (dict, list, default=None) – Single or list of
get_sim_iddictionaries with keyskeys(). A run (row) is created for each brick name and each of these dictionaries.stages (list, string, default=None) – Stages (same for each row of the output catalog).
- Returns
self – New instance.
- Return type
- classmethod from_catalog(cat, list_stages=None, stages=None)¶
Initialize
RunCatalogfrom a catalog.- Parameters
cat (BaseCatalog) – Catalog containing
brickname,keys()andstagesidcolumns.list_stages (ListStages, default=None) – If
None, callgroup_stages()oncat. Else, simply set_list_stagestolist_stages, which should describecat.stagesid.stages (list, string, int, default=None) – Stages (same for each row of the output catalog). If not
None, supersedescatfieldstagesid. Iflist_stagesisNoneandcathas no fieldstagesid, defaults toStages.default().
- Returns
self – New instance.
- Return type
- classmethod from_input_cmdline(opt)¶
Initialize
RunCatalogfrom command-line arguments ofget_input_parser().If ‘list’ is not
None, create new instance withfrom_list(). and applymask_cmdline()i.e. restrict to those runs corresponding to other arguments inopt(ignore ifNone). Else (‘list’ isNone), create new instance withfrom_brick_sim_id()based on other command-line arguments.- Parameters
opt (argparse.Namespace, dict) – Holds options of
get_input_parser().- Returns
self – New instance.
- Return type
- classmethod from_list(fns)¶
Initialize
RunCatalogfrom run list(s) infns.- Parameters
fns (list, string) – Path to run list. If multiple paths are provided, catalogs are appended (see
append()).- Returns
self – New instance corresponding to the input run list(s).
- Return type
Note
Column
stagesidcan be modified, in particular if more than one run lists are provided.
- classmethod from_output_cmdline(opt, force_from_disk=False)¶
Initialize
RunCatalogfrom command-line arguments ofget_output_parser().If all arguments of
get_output_parser()are provided, create instance folowingfrom_input_cmdline(). Ifforce_from_disk == True, further restrict to those runs for which catalogs are written on disk (default file type is ‘tractor’ except if ‘stages’ is notNone, in which case default is ‘pickle’).Else, explore the legacyipe or legacysim (default ‘source’) file structure to fill in the other command-line arguments; and return new instance.
- Parameters
opt (argparse.Namespace, dict) – Holds options of
get_output_parser().force_from_disk (bool, default=False) – If
Truelimit run list to files that exist on disk.
- Returns
self – New instance.
- Return type
- static get_input_parser(parser=None, add_stages=False)¶
Add parser arguments to define runs.
- Parameters
parser (argparse.ArgumentParser, default=None) – Parser to add (in place) arguments to. If
None, a new one is created.add_stages (bool, default=False) – Add argument ‘–stages’?
- Returns
parser – Parser with arguments.
- Return type
argparse.ArgumentParser
- get_list_stages()¶
Return
_list_stages.
- static get_output_parser(parser=None, add_stages=False, add_filetype=False, add_source=False)¶
Add parser arguments to reconstruct runs from legacypipe or legacysim file structure.
- Parameters
parser (argparse.ArgumentParser, default=None) – Parser to add (in place) arguments to. If
None, a new one is created.add_stages (bool, default=False) – Add argument ‘–stages’ and ‘–pickle’?
add_filetype (bool, default=False) – Add argument ‘–filetype’?
add_source (bool, default=False) – Add argument ‘–source’?
- Returns
parser – Parser with arguments.
- Return type
argparse.ArgumentParser
- group_stages(copy=False)¶
Start from catalog of (brickname x sim id x stage), group rows with same (brickname x sim id) together, stack their stages and add stages id in column
stagesid.List of stages
_list_stagesis cleared beforehand.- Parameters
copy (bool, default=False) – Return copy?
- Returns
runcat – Catalog in correct format (brickname x sim id x stages id).
- Return type
- isin(other, fields=None, ignore_stage_version=False)¶
Return mask selecting rows that are in
otherforfields.- Parameters
other (BaseCatalog) – Other catalog.
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields.ignore_stage_version (bool, default=False) – Ignore stage versions for comparison of field
stagesid. Only used if ‘stagesid’ is infields.
- Returns
mask – Mask.
- Return type
bool ndarray
Note
For this comparison, the column
stagesidofotheris updated such that the mapping to stages inother_list_stagesis the same as forself. Neitherothernorselfis modified in this process.
- iter_index(*args, **kwargs)¶
Yield indices for the different runs in input catalog
cat(seeiter_mask()).
- iter_mask(cat, fields=None)¶
Yield boolean mask for the different runs in input catalog
cat.- Parameters
cat (BaseCatalog) – Catalog to be iterated over.
fields (string, list, default=None) – Single field or list of fields. If
None, use all fields inselfwhich are also incat.
- static kwargs_simids_from_cmdline(opt)¶
Return list of
legacysim.survey.get_sim_iddictionaries from command-line arguments.- Parameters
opt (argparse.Namespace, dict) – Holds options of
get_input_parser().- Returns
kwargs_simids – List of
get_sim_iddictionaries with keyskeys().- Return type
dict list
- mask_cmdline(opt)¶
Return mask corresponding to command-line arguments in
opt: ‘brick’,keys(), ‘stages’, ‘list’.If an argument is not in opt or is
None, no mask is applied.- Parameters
opt (argparse.Namespace, dict) – Holds command-line options.
- Returns
mask – Mask.
- Return type
Bool ndarray
- replace_sim_id(copy=False, kwargs_simids=None)¶
Replace sim id by those in
kwargs_simids.- Parameters
copy (bool, default=False) – Return copy?
kwargs_simids (dict, list, default=None) – Single or list of
get_sim_iddictionaries with keyskeys(). A run (row) is created for each brick name and each of these dictionaries.
- Returns
runcat – New instance.
- Return type
- static set_default_output_cmdline(opt)¶
Set default output command-line options. Change
optin-place.- Parameters
opt (argparse.Namespace, dict) – Command-line options.
- update_stages(copy=False)¶
Remove stages indices of
_list_stageswhich are not instagesid.Hence, modify column
stagesid.- Parameters
copy (bool, default=False) – Return copy?
- Returns
runcat – New instance.
- Return type
- without_stage_versions(copy=False)¶
Return catalog without caring for stage versions.
Namely, stages with same names but with different module versions are considered the same. Then,
_list_stagesis reduced to the unique stages, and columnstagesidis updated.- Parameters
copy (bool, default=False) – Return copy?
- Returns
runcat – Catalog without stage versions.
- Return type
- write_list(fn)¶
Write run list to
fn.- Parameters
fn (string) – Path to run list.
- writeto(*args, primheader=None, **kwargs)¶
Write catalog, saving stages in header.
- class legacysim.catalog.SimCatalog(*args: Any, **kwargs: Any)¶
Bases:
legacysim.catalog.BaseCatalogExtend
BaseCatalogwith convenient methods for handling sources injected by legacysim.Call
astrometry.util.fits.fits_table().For an empty catalog, one can provide size or length, to define
len(), used in methods to buildnumpyarrays (e.g.zeros()). Otherwise,len()is set when the first column is added.- fill_legacysim(survey=None, seed=None)¶
Add columns required for legacysim (if not already in
self):id: defaults toindex()brickname, (brick)bx,bycoordinates: based onsurveyandra,decseed: random seed based onseed.
Other columns required by legacysim are:
ra,dec: coordinates (degree)flux_g,flux_r,flux_z: including galactic extinction (nanomaggies)sersic: Sersic indexshape_r: half light radius (arcsecond)shape_e1,shape_e2: ellipticities.
- Parameters
survey (LegacySurveyData, string, default=None) –
survey_diror survey. Used to determine brick-related quantities (brickname,bx,by). IfNone, brick-related quantities are inferred fromdesiutil.brick.Bricks(seeBrickCatalog).seed (int, default=None) – Used to fill or replace ‘seed’ column if not
None.
References
https://en.wikipedia.org/wiki/Sersic_profile https://www.legacysurvey.org/dr8/catalogs
- get_extinction(band, camera='DES')¶
Return SFD extinction given
bandandcamera.Calls
utils.get_extinction().- Parameters
band (string) – Photometric band.
camera (string, default=`DES`) – camera.
- Returns
extinction – Extinction (mag).
- Return type
ndarray
- mask_collisions(radius_in_degree=0.001388888888888889)¶
Return mask of collided objects.
Calls
utils.mask_collisions().- Parameters
radius_in_degree (float, default=5./3600.) – Collision radius (degree).
- Returns
mask – Mask of collided objects.
- Return type
bool ndarray
- match_radec(other, radius_in_degree=0.001388888888888889, **kwargs)¶
Match
selfandotherra,dec.Calls
utils.match_radec().- Parameters
other (SimCatalog) – Catalog to be matched against
self.radius_in_degree (float, default=5./3600.) – Collision radius (degree).
kwargs (dict) – Arguments for
utils.match_radec().
- Returns
index_self (ndarray) – Indices of matching points in
self.index_other (ndarray) – Indices of matching points in
other.
- class legacysim.catalog.Stages(stages=None)¶
Bases:
collections.UserDictHandle (stage,versions) mapping. Keys sorted in
legacypipe.runbrickchronological order.- _all¶
All stages of
legacypipe.runbrick.- Type
list
- _default¶
Default stage name.
- Type
string
If
stagesisNone, include only stage ‘writecat’. Else,stagescan be:a dictionary of (key,value) = (stage,versions)
a list of tuples: ‘[(stage1,versions1), (stage2,versions2)]’
a list of strings: ‘[‘stage1:versions1’, ‘stage2:versions2’]’
a string: ‘stages1:versions1 stages2:versions2’
- isin(other)¶
Return mask selecting stages of
selfthat are inother.- Parameters
other (Stages) – Other stages.
- Returns
mask – Mask.
- Return type
list
- keys()¶
Return keys sorted by chronological order in
legacypipe.runbrick.
- without_versions()¶
Return copy with empty versions.
- class legacysim.catalog.Versions(*args, **kwargs)¶
Bases:
collections.UserDictHandle (module,version) mapping. No order relation.
If no
argsprovided,kwargsshould contain (module,version) mapping. If oneargsprovided, can be:a dictionary of (key,value) = (module,version)
a list of tuples: ‘[(module1,version1), (module2,version2)]’
a list of strings: ‘[‘module1:version1’, ‘module2:version2’]’
a string: ‘module1:version1,module2:version2’
- keys()¶
Return keys sorted in alphabetical order.
legacysim.utils module¶
Convenient functions to handle legacysim inputs/outputs.
- class legacysim.utils.MonkeyPatching¶
Bases:
objectClass to add attributes to modules, e.g.:
import module with MonkeyPatching() as mp: mp.add(module,'function',fun) # module.function is fun # module.function is original function if exists
- _old¶
Dictionary holding original attributes.
- Type
dict
- _new¶
Dictionary holding new (temporary) attributes.
- Type
dict
Create internal dictionaries :attr:_old and :attr:_new.
- add(mod, name, attr)¶
Add attribute
attrwith namenameto modulemod(and savemod.nameif already exists).
- clear()¶
Remove all added (module,name) ties.
- keys()¶
Return (module,name) keys.
- remove(mod, name)¶
Remove added tie of
nameto modulemodand restores the old one if exists.
- legacysim.utils.get_extinction(ra, dec, band=None, camera='DES')¶
Return SFD extinction given
ra,dec,bandandcamera.If
bandnot provided, return EBV.- Parameters
ra (float, array-like) – Right ascension (degree).
dec (float, array-like) – Declination (degree).
band (string, default=None) – Photometric band. If not provided, returns EBV.
camera (string, default=`DES`) – Camera.
- Returns
extinction – Extinction.
- Return type
float, ndarray
- legacysim.utils.get_parser_action_by_dest(parser, dest)¶
Return parser action corresponding to
dest.- Parameters
parser (argparse.ArgumentParser) – Parser.
dest (string) – Parser
destinationargument.
- Returns
act – Action.
- Return type
argparse._StoreAction
- legacysim.utils.get_parser_args(args=None)¶
Transform args (
None,str,list,dict) to parser-compatible (list of strings) args.- Parameters
args (string, list, dict, default=None) – Arguments. If dict, ‘–’ are added in front and there should not be positional arguments.
- Returns
args – Parser arguments.
- Return type
None, list of strings.
Notes
All non-strings are converted to strings with
str().
- legacysim.utils.get_radecbox_area(ramin, ramax, decmin, decmax)¶
Return area of ra, dec box.
- Parameters
ramin (float, array-like) – Minimum right ascension (degree).
ramax (float, array-like) – Maximum right ascension (degree).
decmin (float, array-like) – Minimum declination (degree).
decmax (float, array-like) – Maximum declination (degree).
- Returns
area – Area (degree^2).
- Return type
float, ndarray.
- legacysim.utils.get_shape_ba(e)¶
Return minor-to-major axis ratio
bagiven ellipticitye.- Parameters
e (float, ndarray) – Ellipticity.
- Returns
ba – Minor-to-major axis ratio (b/a).
- Return type
float, ndarray
References
- legacysim.utils.get_shape_ba_phi(e1, e2)¶
Return minor-to-major axis ratio
baand anglephigiven ellipticitiese1,e2.- Parameters
e1 (float, ndarray) – Ellipticity component 1.
e2 (float, ndarray) – Ellipticity component 2.
- Returns
ba (float, ndarray) – Minor-to-major axis ratio (b/a).
phi (float, ndarray) – Angle (radian).
References
- legacysim.utils.get_shape_e(ba)¶
Return ellipticity
egiven minor-to-major axis ratioba.- Parameters
ba (float, ndarray) – Minor-to-major axis ratio (b/a).
- Returns
e – Ellipticity.
- Return type
float, ndarray
References
https://www.legacysurvey.org/dr8/catalogs/ Warning! Corresponds to g in: https://galsim-developers.github.io/GalSim/_build/html/shear.html#
- legacysim.utils.get_shape_e1_e2(ba, phi)¶
Return ellipticities e1, e2 given minor-to-major axis ratio
baand anglephi.- Parameters
ba (float, ndarray) – Minor-to-major axis ratio (b/a).
phi (float, ndarray) – Angle in radians.
- Returns
e1 (float, ndarray) – Ellipticity component 1.
e2 (float, ndarray) – Ellipticity component 2.
References
- legacysim.utils.list_parser_dest(parser, exclude=('help',))¶
Return parser list of
dest.- Parameters
parser (argparse.ArgumentParser) – Parser.
exclude (list, tuple, default=('help',)) – Brick name.
- Returns
args – Parser list of
dest.- Return type
list
- legacysim.utils.mag2nano(mag)¶
Convert magnitudes to nanomaggies.
- legacysim.utils.mask_collisions(ra, dec, radius_in_degree=0.001388888888888889)¶
Return mask of collided objects.
- Parameters
ra (array-like) – Right ascension (degree).
dec (array-like) – Declination (degree).
radius_in_degree (float, default=5./3600.) – Collision radius (degree).
- Returns
mask – Mask of collided objects.
- Return type
bool ndarray
- legacysim.utils.match_id(id1, id2)¶
Match id2 to id1.
- Parameters
id1 (array-like) – IDs 1, should be unique.
id2 (array-like) – IDs 2, should be unique.
- Returns
index1 (ndarray) – Indices of matching
id1.index2 (ndarray) – Indices of matching
id2.
Warning
Makes sense only if
id1andid2elements are unique.References
- legacysim.utils.match_radec(ra1, dec1, ra2, dec2, radius_in_degree=None, return_distance=False, notself=False, nearest=True)¶
Match ra2,dec2 to ra1,dec1.
All quantities in degree. Uses https://github.com/dstndstn/astrometry.net/blob/master/libkd/spherematch.py.
- Parameters
ra1 (array-like) – Right ascension 1 (degree).
dec1 (array-like) – Declination 1 (degree).
ra2 (array-like) – Right ascension 2 (degree).
dec2 (array-like) – Declination 2 (degree).
radius_in_degree (float,default=None) – If not None, maximum radius (degree) to match ra, dec pairs.
return_distance (bool, default=False) – If
True, return distance.notself (bool, default=False) – If
True, avoids returning ‘identity’ matches, i.e. ra1,dec1 == ra2,dec2.nearest (bool, default=True) – If
True, returns only the nearest match in (ra2,dec2) for each point in (ra1,dec1). Else, returns all matches (index1 and index2 are not made of unique elements).
- Returns
index1 (ndarray) – Indices of ra1,dec1 matching points.
index2 (ndarray) – Indices of ra2,dec2 matching points.
distance (ndarray) – Distance (degree).
- legacysim.utils.mkdir(dirnm)¶
Try to create
dirnmand catchOSError.
- legacysim.utils.nano2mag(nano)¶
Convert nanomaggies to magnitudes.
- legacysim.utils.sample_ra_dec(size=None, radecbox=(0.0, 360.0, - 90.0, 90.0), rng=None, seed=None)¶
Sample uniform ra, dec coordinates in
radecbox.Taken from https://github.com/desihub/imaginglss/blob/master/scripts/imglss-mpi-make-random.py.
- Parameters
size (int, default=None) – Number of objects. If
None, only a single tuple ra, dec will be sampled.radecbox (list, tuple, default=(0.,360.,-90.,90.)) – ramin, ramax, decmin, decmax.
rng (np.random.RandomState, default=None) – Random state; If
None, build RandomState fromseed.seed (int, default=None) – Random seed, only used if
rngis None.
- Returns
ra (float, ndarray) – Right ascension (degree).
dec (float, ndarray) – Declination (degree).
- legacysim.utils.savefig(fn, bbox_inches='tight', pad_inches=0.1, dpi=200, **kwargs)¶
Save matplotlib figure to
fn.
- legacysim.utils.saveplot(giveax=True)¶
Decorate plotting methods, to achieve the following behaviour for the decorated method:
If
axis provided, add image toax. Else, iffnis provided, save image tofn, with argumentskwargs_fig. Else, show image.- Parameters
giveax (bool, default=True) – If
True, provideaxto decorated method. Else,axis not provided.
- legacysim.utils.setup_logging(level=20, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, filename=None, filemode='w', **kwargs)¶
Set up logging.
- Parameters
level (string, int, default=logging.INFO) – Logging level.
stream (_io.TextIOWrapper, default=sys.stdout) – Where to stream.
filename (string, default=None) – If not
Nonestream to file name.filemode (string, default='w') – Mode to open file, only used if filename is not
None.kwargs (dict) – Other arguments for
logging.basicConfig().
legacysim.runbrick module¶
legacysim main executable, extend legacypipe.runbrick.
- legacysim.runbrick.get_parser()¶
Append legacysim arguments to those of
legacypipe.runbrick.get_parser().- Returns
parser (argarse.ArgumentParser) – Parser.
args_runbrick (list) – List of legacypipe-specific arguments.
- legacysim.runbrick.get_runbrick_kwargs(args_runbrick, **opt)¶
Convert
legacysim.runbrickcommand line options intosurveyand**kwargsforrun_brick().Wraps
legacypipe.runbrick.get_runbrick_kwargs().- Parameters
args_runbrick (list) – List of legacypipe-specific arguments.
opt (dict) – Dictionary of the command line options for
legacysim.runbrick.
- Returns
survey (LegacySurveySim instance) – Survey, without
injected.kwargs (dict) –
Arguments for
legacypipe.runbrick.run_brick()following:run_brick(brickname, survey, **kwargs)
- legacysim.runbrick.main(args=None)¶
Main routine which parses the optional inputs.
Essentially copy-paste from
legacypipe.runbrick.main(), main changes:parser = get_parser() survey, kwargs = get_runbrick_kwargs(**optdict) run_brick(opt.brick, survey, **kwargs)
to:
parser, args_runbrick = get_parser() survey, kwargs = get_runbrick_kwargs(args_runbrick,**optdict) run_brick(opt, survey, **kwargs)
- Parameters
args (list, default=None) – To overload command line arguments.
- legacysim.runbrick.run_brick(opt, survey, **kwargs)¶
Add
injectedtosurvey, run brick, and savesinjected.Wraps
legacypipe.runbrick.run_brick().- Parameters
opt (Namespace) – Command line options for
legacysim.runbrick.survey (LegacySurveySim instance) – Survey, without
injected.kwargs (dict, default={}) –
Arguments for
legacypipe.runbrick.run_brick()following:run_brick(brickname, survey, **kwargs)
- Returns
toret – Dictionary returned by
legacypipe.runbrick.run_brick().- Return type
dict
- legacysim.runbrick.set_brick(opt)¶
If no brick name provided in
opt(opt.radec == None), build it from ra, dec and updateopt.brick.Copy-pasted from
legacypipe.runbrick.run_brick().- Parameters
opt (argparse.Namespace) – Command-line arguments.
- legacysim.runbrick.wrapper_add_stage_version(legacypipe_add_stage_version)¶
Wrap
legacypipe.runbrick._add_stage_version()to add legacysim stage version.
- legacysim.runbrick.wrapper_get_dependency_versions(legacypipe_get_dependency_versions)¶
Wrap
legacypipe.survey.get_dependency_versions()to add legacysim dependency versions (galsim).
- legacysim.runbrick.wrapper_get_version_header(legacypipe_get_version_header)¶
Wrap
legacypipe.survey.get_version_header()to add legacysim version.
legacysim.analysis module¶
Convenient classes to perform legacysim analysis: image cutouts, catalog merging, catalog matching, computing time.
- class legacysim.analysis.BaseImage¶
Bases:
objectDumb class to read, slice and plot an image.
- img¶
Image (indexed by
img[y,x]), may be multi-dimensional.- Type
ndarray
- xmin¶
x-coordinate of
(0,0)corner.- Type
int, float
- ymin¶
y-coordinate of
(0,0)corner.- Type
int, float
- isRGB()¶
Whether image is multi-dimensional.
- plot(ax, cmap='gray', vmin=None, vmax=None, kwargs_range=None)¶
Plot image.
- Parameters
ax (plt.axes.Axes) – Where to plot image. One can also provide figure file name
fn. Seeutils.saveplot.cmap (string, plt.Colormap, default='gray') – Color map for
pyplot.imshow(), ignore in case of RGB(A) image.vmin (float, default=None) – Minimum value for
cmap.vmax (float, default=None) – Maximum value for
cmap.kwargs_range (dict, default=None) – If provided, provided to
Binningto determinevminandvmax.
- read_image(fn, fmt='jpeg', xmin=0, ymin=0, **kwargs)¶
Read image, either in ‘jpeg’ or ‘fits’ fmt and add
imgtoself.- Parameters
fn (string) – Image filename.
fmt (string, defaut='jpeg') – Image format, ‘jpeg’ or ‘fits’. If ‘jpeg’,
self.imgwill have shape(H,W,3). If ‘fits’,self.imgwill have shape(H,W).xmin (int, float, default=0) – x-coordinate of
(0,0)corner.ymin (int, float, default=0) – y-coordinate of
(0,0)corner.kwargs (dict, default={}) – Arguments to be passed to
pyplot.imread()orfitsio.read().
- set_subimage(slicex=slice(0, None, None), slicey=slice(0, None, None))¶
Slice image and update
xmin,yminaccordingly.Slices should be zero-indexed, in the image coordinates (i.e. do not account for
xminandymin).
- property shape¶
Return image shape (H,W).
If image does not exist, defaults to
_shape_default.
- class legacysim.analysis.Binning(samples=None, weights=None, edges=None, nbins=10, range=None, quantiles=None, scale='linear')¶
Bases:
objectCreate edges to bin samples.
- edges¶
Edges to bin samples.
- Type
ndarray
First set the total range, then the number of bins with
numpy.histogram_bin_edges().- Parameters
samples (array-like) – Samples to be binned.
weights (array-like, default=None) – Weights associated to
samples, used bynumpy.histogram_bin_edges(). IfNone, defaults to 1.edges (array-like, default=None) – If edges already provided, nothing to do!
nbins (int, string, default=None) – Number of bins. If
int, used to defineedgesusingscale. Else, passed on tonumpy.histogram_bin_edges().range (array-like, default=None) – Range, i.e.
edgesminimum and maximum boundaries. If notNone, supersedesquantiles.quantiles (array-like, default=None) – Quantiles (low,up) to define
range. IfNone, setrangetosamplesminimum and maximum.scale (string, default='linear') – Used if
nbinsisint. If ‘linear’, use a linear binning. If ‘log’, use a logarithmic binning.
- property centers¶
Return bin centers.
- property nbins¶
Return number of bins.
- property range¶
Return
edgesminimum and maximum boundaries.
- class legacysim.analysis.CatalogMatching(base_dir='.', runcat=None, bricknames=None, kwargs_simids=None, source='legacysim', cats_dir=None, save_fn=None)¶
Bases:
legacysim.analysis.CatalogMergingExtend
CatalogMergingwith methods to match input and output catalogs.- input¶
Catalog of input sources.
- Type
- output¶
Catalog of output sources.
- Type
Set legacysim or legacypipe file structure.
- Parameters
base_dir (string, default='.') – legacysim (if
source == 'legacysim') or legacypipe (ifsource == 'legacypipe') root file directory.runcat (RunCatalog, defaut=None) – Run catalog used to select files from legacysim or legacypipe data structure. If provided, supersedes
bricknamesandkwargs_simids.bricknames (list, default=None) – List of brick names.
kwargs_simids (dict, list, default=None) – Single or list of
get_sim_iddictionaries with keyskeys().source (string, default='legacysim') – If ‘legacysim’, search for legacysim file names, else legacypipe file names.
cats_dir (string, default=None) – Directory where to save merged catalogs.
save_fn (string, default=None) – File name where to save
self.
- export(base='input', key_input='input', key_output=None, key_distance='distance', key_matched='matched', key_injected='injected', injected=False, write=False, **kwargs_write)¶
Export the matched catalog obtained with
match().- Parameters
base (string, default='input') – Base for matched catalog. Can be: - ‘input’: output columns are added to input - ‘output’: input columns are added to output - ‘inter’: as ‘input’, but matched sources only are kept - ‘extra’: keep only sources which could not be matched, in either input or output - ‘all’: stack all sources in both input and output
key_input (string, default='input') – If not
None, prefix to add to input fields.key_output (string, default=None) – If not
None, prefix to add to output fields.key_distance (string, default='distance') – If not
None, field to save angular distance between matched input and output sources.key_matched (string, default='matched') – If not
None, field to save boolean mask identifying matched input and output sources.key_injected (string, default='injected') – If not
None, field to save boolean mask identifying injected sources.injected (bool, default=False) – If
True, restrict to injected sources.write (bool, default=False) – Write catalog to disk.
kwargs_write (dict) – Arguments for
write_catalog().
- Returns
cat – Catalog of input - output sources.
- Return type
- getstate()¶
Export
selftodict.
- match(radius_in_degree=0.0004166666666666667, add_input_tractor=False)¶
-
- Parameters
radius_in_degree (float, default=1.5/3600.) – Radius (degree) for input - output matching.
add_input_tractor (bool, string, default=False) – Passed on to
setup().
- plot_hist(ax, field, injected=True, xlabel=None, ylabel=None, divide_uncer=True, label_entries=True, label_mean_std=True, kwargs_xedges=None, kwargs_hist=None)¶
Histogram of
outputv.s.inputdifferences.- Parameters
ax (plt.axes.Axes) – Where to plot.
field (string) – Name of catalog column to plot.
injected (bool, default=True) – If
True, restrict to injected sources. Else all (actual and injected) sources are considered.xlabel (string, default=None) – x-label, if
None, defaults to'input_%s' % field.ylabel (string, default=None) – y-label, if
None, defaults to'output_%s' % field.divide_uncer (bool, default=True) – If
True, divide the differenceoutput - inputby the estimated uncertainty.label_entries (bool, default=True) – If
True, add the number of entries to the plot.label_mean_std (bool, default=True) – If
True, add the estimated mean, median, standard deviation to the plot.kwargs_xedges (dict, default=None) – Arguments for
Binning, to define the x-edges.kwargs_hist (dict, default=None) – Extra arguments for
pyplot.hist().
- plot_scatter(ax, field, injected=True, xlabel=None, ylabel=None, square=False, regression=False, diagonal=False, label_entries=True, kwargs_xlim=None, kwargs_ylim=None, kwargs_scatter=None, kwargs_regression=None, kwargs_diagonal=None)¶
Scatter plot
outputv.s.input.- Parameters
ax (plt.axes.Axes) – Where to plot.
field (string) – Name of catalog column to plot.
injected (bool, default=True) – If
True, restrict to injected sources. Else all (actual and injected) sources are considered.xlabel (string, default=None) – x-label, if
None, defaults to'input_%s' % field.ylabel (string, default=None) – y-label, if
None, defaults to'output_%s' % field.square (bool, default=False) – If
True, enforce square plot.regression (bool, default=False) – If
False, plot regression line.diagonal (bool, default=False) – If
False, plot diagonal line.label_entries (bool, default=True) – If
True, add the number of entries to the plot.kwargs_xlim (dict, default=None) – Arguments for
Binning, to define the x-range.kwargs_ylim (dict, default=None) – Arguments for
Binning, to define the y-range.kwargs_scatter (dict, default=None) – Extra arguments for
pyplot.scatter().kwargs_regression (dict, default=None) – Extra arguments for
pyplot.plot()regression line.kwargs_diagonal (dict, default=None) – Extra arguments for
pyplot.plot()diagonal line.
- setstate(state)¶
Add
statetoself.
- setup(add_input_tractor=False)¶
Add
inputandoutputTractor catalog toself.By default, only the sources injected by legacysim are considered for
input. These can be merged to the sources detected by legacypipe by settingadd_input_tractor.- Parameters
add_input_tractor (bool, string, default=False) – If
True, legacypipe Tractor catalogs are added toinput. In this casebase_diris considered as the legacyipe root directory. Ifstring, specifies the path to the legacyipe root directory.
- class legacysim.analysis.CatalogMerging(base_dir='.', runcat=None, bricknames=None, kwargs_simids=None, source='legacysim', cats_dir=None, save_fn=None)¶
Bases:
objectClass to load, merge and save legacyipe and legacysim catalogs.
- base_dir¶
See below.
- Type
string
- runcat¶
See below.
- Type
- source¶
See below.
- Type
string
- cats¶
Dictionary holding catalogs.
- Type
dict
- cats_fn¶
Dictionary holdind catalog file names.
- Type
dict
- cats_dir¶
See below.
- Type
string
- save_fn¶
See below.
- Type
string
Set legacysim or legacypipe file structure.
- Parameters
base_dir (string, default='.') – legacysim (if
source == 'legacysim') or legacypipe (ifsource == 'legacypipe') root file directory.runcat (RunCatalog, defaut=None) – Run catalog used to select files from legacysim or legacypipe data structure. If provided, supersedes
bricknamesandkwargs_simids.bricknames (list, default=None) – List of brick names.
kwargs_simids (dict, list, default=None) – Single or list of
get_sim_iddictionaries with keyskeys().source (string, default='legacysim') – If ‘legacysim’, search for legacysim file names, else legacypipe file names.
cats_dir (string, default=None) – Directory where to save merged catalogs.
save_fn (string, default=None) – File name where to save
self.
- get(*args, **kwargs)¶
Return
selfattribute.
- get_key(filetype='tractor', source=None)¶
Return key to catalog in
cats.- Parameters
filetype (string, default=None) – Type of file.
source (string, default=None) – If not
None, supersedesself.source.
- Returns
key – Key in
cats.- Return type
string
- getstate()¶
Export
selftodict.
- has(*args, **kwargs)¶
Has
selfthis attribute?
- classmethod load(save_fn)¶
Load
selffrom disk.- Parameters
save_fn (string) – File name where
selfis saved.
- merge(filetype='tractor', base_dir=None, source=None, keep_columns=None, add=False, write=False, **kwargs_write)¶
Merge catalogs, return the result and add to
self(add == True) and/or directly write on disk (write == True).- Parameters
filetype (string, default='tractor') – Type of file to merge.
base_dir (string, default=None) – legacysim (if
source == 'legacysim') or legacypipe (ifsource == 'legacypipe') root file directory. If notNone, supersedesbase_dir.source (string, default=None) – If ‘legacysim’, search for an legacysim file name, else a legacypipe file name. If not
None, supersedessource.keep_columns (list, default=None) – Keep only these columns.
add (bool, default=False) – Add merged catalog to
self.write (bool, default=False) – Write merged catalog to disk.
kwargs_write (bool) – If
write, arguments to pick up catalog file name. Seeset_cat_fn().
- Returns
cat – Merged catalog.
- Return type
- read_catalog(add=False, **kwargs)¶
Read catalog from disk.
- Parameters
add (bool, default=False) – Add catalog to
self.kwargs (dict) – Arguments for
set_cat_fn(), to set catalog file name.
- save(save_fn=None)¶
Save
selfto disk.- Parameters
save_fn (string, default=None) – File name where to save
self. If notNone, supersedesself.save_fn.
- set(*args, **kwargs)¶
Set
selfattribute.
- set_cat_fn(cat_base=None, cat_fn=None, **kwargs_key)¶
Set catalog file name.
- set_catalog(name, filetype=None, source=None, **kwargs_merge)¶
Convenience function to add catalog to
selfwith namename.First try to get it from
cats. Else if the file name is specified incats_fn, read the merged catalog from disk. Else merge catalogs.
- setstate(state)¶
Add
statetoself.
- write_catalog(cat=None, **kwargs)¶
Write catalog to disk.
- Parameters
cat (SimCatalog, default=None) – Catalog to save. If
None, is got fromcats.kwargs (dict) – Arguments for
set_cat_fn(), to set catalog file name.
- class legacysim.analysis.ImageAnalysis(base_dir='.', brickname=None, kwargs_simid=None, source='legacysim')¶
Bases:
legacysim.analysis.BaseImageExtend
BaseImagewith legacysim-related convenience functions.- _shape_default¶
Default shape.
- Type
tuple
- base_dir¶
See below.
- Type
string
- source¶
See below.
- Type
string
- sources¶
Injected sources, see
read_sources().- Type
Set legacysim or legacypipe file structure.
- Parameters
base_dir (string, default='.') – legacysim or legacypipe root file directory.
brickname (string, default=None) – Brick name.
kwargs_simid (dict, default=None) –
get_sim_iddictionary with keyskeys().source (string, default='legacysim') – If ‘legacysim’, search for legacysim file names, else legacypipe file names.
- get_zooms(boxsize_in_pixels=None, full_only=False)¶
Return image cutouts around attr:sources.
- Parameters
boxsize_in_pixels (int, default=None) – Box size (pixel) around the attr:sources. If
None, defaults to image smaller side divided by 36.full_only (bool, default=False) – Return only the cutouts which are not cropped in the edges.
- Returns
slices (list) – List of slices
(slicex,slicey), to be passed toset_subimage().indices (ndarray) – If
full_only == True, corresponding indices insources.
- plot_sources(ax, radius_in_pixel=11.450381679389313, dr=None, color='r')¶
Plot circles around
sources.- Parameters
ax (plt.axes.Axes) – Where to plot sources.
radius_in_pixel (float, default=3./0.262) – Radius (pixel) around sources.
dr (float, default=None) – Circle width (pixel). If
None, defaults toradius_in_pixel/20.color (string, default='r') – Circle color.
- read_image(filetype='image-jpeg', band=None)¶
Read legacysim image and add
imgtoself.- Parameters
filetype (string, default='image-jpeg') – Image file type. See
legacypipe.survey.LegacySurveyData.find_file().band (list, tuple, string, default=None) – Image band(s). Only used in case the image is in ‘fits’ format. In this case, if band is a list, should be of length 3 to build up a RGB image with
legacypipe.survey.get_rgb(). IfNone, defaults to['g','r','z']. Else, only the image in the corresponding band is read.
- read_image_wcs(filetype='image', band='g', ext=1)¶
Read image wcs.
- Parameters
filetype (string, default='image-jpeg') – File type to read wcs from. See
legacypipe.survey.LegacySurveyData.find_file().band (string, default='g') – Image band(s). Shoud not matter.
ext (int, default=1) – FITS extension to read header from.
- read_sources(base_dir=None, filetype='injected', source='legacysim')¶
Read sources in the image add
sourcestoself.- Parameters
base_dir (string, defaut=None) – If not
None, supersedesbase_dir.filetype (string, default='injected') – File type of sources. See
legacysim.survey.find_file().source (string, default='legacysim') – If ‘legacysim’, search for legacysim file name, else legacypipe file name. If not
None, supersedessource.
- suggest_zooms(boxsize_in_pixels=None, match_in_degree=2.777777777777778e-05, range_observed_injected_in_degree=(0.001388888888888889, 0.008333333333333333))¶
Suggest image cutouts around attr:sources and within some distance to Tractor sources.
- Parameters
boxsize_in_pixels (int, default=None) – Box size (pixel) around the attr:sources; see
get_zooms().match_in_degree (float, default=0.1/3600) – Radius (degree) to match attr:sources to Tractor sources.
range_observed_injected_in_degree (tuple, list, default=(5./3600,30./3600)) – Range (degree) around the attr:sources where to find a Tractor source.
- Returns
slices (list) – List of slices
(slicex,slicey), to be passed toset_subimage().indices (ndarray) – Corresponding indices in
sources.
- class legacysim.analysis.ResourceAnalysis(base_dir='.', runcat=None, bricknames=None, kwargs_simids=None, source='legacysim', cats_dir=None, save_fn=None)¶
Bases:
legacysim.analysis.ResourceEventAnalysisExtend events-only analyzes of
ResourceEventAnalysiswith analysis of full time series saved inpsfiles.- series¶
Concatenated time series read from
psfiles.- Type
Set legacysim or legacypipe file structure.
- Parameters
base_dir (string, default='.') – legacysim (if
source == 'legacysim') or legacypipe (ifsource == 'legacypipe') root file directory.runcat (RunCatalog, defaut=None) – Run catalog used to select files from legacysim or legacypipe data structure. If provided, supersedes
bricknamesandkwargs_simids.bricknames (list, default=None) – List of brick names.
kwargs_simids (dict, list, default=None) – Single or list of
get_sim_iddictionaries with keyskeys().source (string, default='legacysim') – If ‘legacysim’, search for legacysim file names, else legacypipe file names.
cats_dir (string, default=None) – Directory where to save merged catalogs.
save_fn (string, default=None) – File name where to save
self.
- add_event_vlines(ax, events=None)¶
Plot vertical lines to indicate start of events.
- Parameters
ax (plt.axes.Axes) – Where to plot events.
events (array-like, string, default=None) – Passed on to
process_events().
- plot_all_series(ax, events='stage', processes=None, label_entries=True, kwargs_plot=None)¶
Plot summary resources for all time series.
- Parameters
ax (plt.axes.Axes) – Where to plot the time series. One can also provide figure file name
fn. Seelegacysim.utils.saveplot().events (array-like, string, default='stage') – Passed on to
process_events().processes (list, default=None) – Processes to plot. If
None, defaults to['main','workers']. If ‘all’, plot all processes ofprocess_one_series().label_entries (bool, default=True) – If
True, add number of entries to plot.kwargs_plot (dict, default=None) – Extra arguments for
pyplot.plot().
- plot_one_series(ax, series=None, events='stage', processes=None, kwargs_fig=None, kwargs_plot=None)¶
Plot resources for a single time series.
- Parameters
ax (plt.axes.Axes) – Where to plot the time series. One can also provide figure file name
fn. Seelegacysim.utils.saveplot().series (SimCatalog, default=None) – Time series to analyze. If
None, defaults toseries.events (array-like, string, default='stage') – Passed on to
process_events().processes (list, default=None) – Processes to plot. If
None, defaults to['main','workers']. If ‘all’, plot all processes ofprocess_one_series().kwargs_fig (dict, default=None) – Extra arguments for
pyplot.savefig(). Seelegacysim.utils.saveplot().kwargs_plot (dict, default=None) – Extra arguments for
pyplot.plot().
- process_all_series(quantities=None)¶
Compute average resources for all time series, split between the following categories: ‘ps’ (the process running ps), ‘main’ (the master process), ‘workers’ (non-zero in case of multithreading), ‘others’ (other processes).
- Parameters
quantities (list, default=None) – Quantities to analyze. If
None, defaults to['proc_icpu','vsz'].- Returns
stats – A dictionary holding summary time series for each quantity and process category.
- Return type
dict
- static process_one_series(series, quantities=None)¶
Compute resources for a single time series, split between the following categories: ‘ps’ (the process running ps), ‘main’ (the master process), ‘workers’ (non-zero in case of multithreading), ‘others’ (other processes).
- Parameters
series (SimCatalog) – Time series to analyze.
quantities (list, default=None) – Quantities to analyze. If
None, defaults to['proc_icpu','vsz'].
- Returns
stats – A dictionary holding time series for each quantity and process category.
- Return type
dict
- class legacysim.analysis.ResourceEventAnalysis(base_dir='.', runcat=None, bricknames=None, kwargs_simids=None, source='legacysim', cats_dir=None, save_fn=None)¶
Bases:
legacysim.analysis.CatalogMergingExtend
CatalogMergingwith methods to analyze computing time based on events saved inpsfiles.- _sorted_events¶
Events sorted by chronological order.
- Type
list
- events¶
Concatenated events read from
psfiles.- Type
Set legacysim or legacypipe file structure.
- Parameters
base_dir (string, default='.') – legacysim (if
source == 'legacysim') or legacypipe (ifsource == 'legacypipe') root file directory.runcat (RunCatalog, defaut=None) – Run catalog used to select files from legacysim or legacypipe data structure. If provided, supersedes
bricknamesandkwargs_simids.bricknames (list, default=None) – List of brick names.
kwargs_simids (dict, list, default=None) – Single or list of
get_sim_iddictionaries with keyskeys().source (string, default='legacysim') – If ‘legacysim’, search for legacysim file names, else legacypipe file names.
cats_dir (string, default=None) – Directory where to save merged catalogs.
save_fn (string, default=None) – File name where to save
self.
- plot_bar(ax, events='stage', label_entries=True, kwargs_bar=None)¶
Plot event mean and standard deviation in the form of a bar graph.
- Parameters
ax (plt.axes.Axes) – Where to plot image. One can also provide figure file name
fn. Seelegacysim.utils.saveplot().events (array-like, string, default=None) – Passed on to
process_events().label_entries (bool, default=True) – If
True, add the number of entries to the plot.kwargs_bar (dict, default=None) – Extra arguments for
pyplot.bar().
- process_events(events=None, time='reltime', statistic='mean')¶
Return statistics about event durations. Assumes event are recorded at the beginning of the corresponding step.
- Parameters
events (array-like, string, default=None) – List of events to get statistics from, e.g.
['stage_halos: starting']. Seeself._sorted_events. IfNone, consider all events. Ifstage, consider only starting stage events('stage_xxx: starting').time (string, default='reltime') – Time to consider for calculation. If ‘reltime’, consider the time at which events happens relative to the beginning of the run. Else, if ‘steptime’, consider the time duration of each event, i.e. the time difference between events, starting from the last time step registered for the run.
statistic (string, callable, default='mean') – Statistic to compute from event time, passed on to
scipy.stats.binned_statistic().
- Returns
events, values – Events and corresponding statistic.
- Return type
ndarray
- legacysim.analysis.estimate_std_outliers(samples)¶
Estimate the standard deviation of
samplesfrom the median of the folded distribution.Less sensitive to outliers than standard deviation.
legacysim.scripts module¶
Script to check all runs have completed by verifying all files exist on disk (and optionally can be opened).
For details, run:
python check.py --help
- legacysim.scripts.check.main(args=None)¶
Check runs.
Script to plot cpu and memory usage.
For details, run:
python resources.py --help
- legacysim.scripts.resources.main(args=None)¶
Plot resources.
Script to merge catalogs of different bricks/runs together.
For details, run:
python merge.py --help
- legacysim.scripts.merge.main(args=None)¶
Merge catalogs.
Script to match catalogs of input and output sources.
For details, run:
python match.py --help
- legacysim.scripts.match.main(args=None)¶
Match input to output catalogs.
Script to produce image cutouts.
For details, run:
python cutout.py --help
- legacysim.scripts.cutout.main(args=None)¶
Plot cutouts of sources.
Script to write run list (eventually accounting for module versions), useful when scheduling jobs.
For details, run:
python runlist.py --help
- legacysim.scripts.runlist.main(args=None, force_write=False)¶
Produce list of runs.
legacysim.batch module¶
Task manager that run tasks in series.
- class legacysim.batch.task_manager.BaseTaskManager¶
Bases:
objectA dumb task manager, that simply iterates through the tasks in series.
- iterate(tasks)¶
Iterate through a series of tasks.
- Parameters
tasks (iterable) – An iterable of tasks that will be yielded.
- Yields
task – The individual items of
`tasks, iterated through in series.
- map(function, tasks)¶
Apply a function to all of the values in a list and return the list of results.
If
taskscontains tuples, the arguments are passed tofunctionusing the*argssyntax.- Parameters
function (callable) – The function to apply to the list.
tasks (list) – The list of tasks.
- Returns
results – The list of the return values of
function.- Return type
list
- legacysim.batch.task_manager.TaskManager(ntasks=None, **kwargs)¶
Switch between non-MPI (ntasks=1) and MPI task managers. To be called as:
with TaskManager(...) as tm: # do stuff
- legacysim.batch.task_manager.run_shell(command, check=False)¶
Run a command in the shell, returning stdout and stderr combined.
Script to set up environment for legacysim runs.
For details, run:
python environment_manager.py --help
- class legacysim.batch.environment_manager.EnvironmentManager(header=None, fn=None, base_dir=None, brickname=None, source='legacypipe', filetype=None, kwargs_simid=None, skip=False)¶
Bases:
objectSet up environment variables for legacysim runs. To be called as:
with EnvironmentManager(...): # do legacysim-related stuff
- header¶
See below.
- Type
fitsio.FITSHDR
- environ¶
Environment variables.
- Type
dict
Note
Only legacypipe and legacysim versions are saved for every stage in catalog headers. Other package versions are saved at the beginning of each run (stage ‘tims’), and hence may not reflect the actual version used in any stage of the run. legacypipe catalog headers can be matched to a version of legacypipe Docker image (see
get_module_version). However, for the same reason as above, this match may be ambiguous for any stage different than ‘tims’.Initialize
EnvironmentManagerby reading the primary header of an output catalog.- Parameters
header (FITSHDR, default=None) – FITS header to read environment from. If not
None, supersedesfn,base_dir,brickname,source,filetype,kwargs_simid.headeris copied intoheader.fn (string, default=None) – Name of Tractor file to read header from. If not
None, supersedesbase_dir,brickname,source,filetype,kwargs_simid.base_dir (string, default=None) – legacysim (if
source == 'legacysim') or legacypipe (ifsource == 'legacypipe') root file directory.brickname (string, default=None) – Brick name.
source (string, default='legacysim') – If ‘legacysim’, search for an legacysim file name, else a legacypipe file name.
filetype (string, default=None) – File type to read primary header from. If
None, defaults to ‘injected’ ifsource == 'legacysim', else ‘tractor’.kwargs_simid (dict, default=None) –
get_sim_iddictionary with keyskeys().skip (bool, default=False) – If
True, do not set environment.
- check_environ()¶
Check whether variables in
environare valid (typically if directory or file exists on disk); else fall back toos.environ.:raises ValueError : If a variable in
environis not valid and there is no fallback value inos.environ.:
- get_module_version(module, stage='writecat')¶
Return module version for stage.
legacypipe and legacysim runs are performed within a Docker container. To return (one of) the Docker image version that matches the module versions in the catalog header, pass
module == 'docker'.- Parameters
module (string) – Module name. If ‘docker’, return a Docker image version by matching module versions to internal
_docker_versions. Ifstage == 'tims'or legacypipe versions are the same for every stage up tostage, match all modules of_docker_versions; else only legacypipe version (at the given stage) is matched to_docker_versions, and the last Docker image version of the obtained matches is returned.stage (string, default='writecat') – Stage name.
- Returns
version – Module version.
- Return type
string
- get_stages_versions(modules)¶
Return a
Stagesinstance with changes in module versions (at least including ‘writecat’).- Parameters
modules (list) – List of module names to get versions for.
- Returns
stages – Stages with mapping (stage name, module versions).
- Return type
- legacysim.batch.environment_manager.get_pythonpath(module_dir='/src/', versions=(), full=False, as_string=False)¶
Return PYTHONPATH.
The path to ‘module’ is set to
module_dir/module_version(/py for legacypipe and legacysim modules).- Parameters
module_dir (string, default='/src/') – Directory containing modules.
versions (Versions, dict, list of tuples, default=()) – (module, version) mapping.
full (bool, default=False) – By default, only PYTHONPATH to modules in
versionsis returned. Iffull == True, append other paths already in current PYTHONPATH.as_string (bool, default=False) – By default, returned value is a list of paths. If
as_string == True, return a string with paths separated by a colon ‘:’.
- Returns
pythonpath – PYTHONPATH.
- Return type
string, list of strings
- legacysim.batch.environment_manager.main(args=None)¶
Print all module paths and environment variables used for the run(s).