survey.polygon#
This module defines the PolygonSurvey class, a survey type where fields are represented as shapely polygons projected onto the sky.
- class skysurvey.survey.polygon.PolygonSurvey(data=None, fields=None)[source]#
Bases:
BaseSurveyThe PolygonSurvey class.
- Parameters:
data (pandas.DataFrame) – observing data.
fields (geopandas.GeoDataFrame) – field definitions.
_DEFAULT_FIELDS (geopandas.GeoDataFrame or None) – The default field definitions for this survey type. Subclasses should override this to provide specific survey grids.
- classmethod from_pointings(data, footprint=None, moc=None, rakey='ra', deckey='dec')[source]#
Load an instance from pointings.
- Parameters:
data (pandas.DataFrame or dict) – observing data, must contain the rakey and deckey columns.
footprint (shapely.geometry) – footprint in the sky of the observing camera
moc (mocpy.MOC) – MOC representation of the observing camera
rakey (str) – name of the R.A. column (in deg)
deckey (str) – name of the Declination column (in deg)
- Return type:
PolygonSurvey
- classmethod from_random(size, bands, mjd_range, skynoise_range, fields=None, **kwargs)[source]#
Load an instance with random observing data.
- Parameters:
- Return type:
PolygonSurvey
- get_fields(observed=True)[source]#
Get the fields.
- Parameters:
observed (bool) – if True, return only the observed fields.
- Return type:
geopandas.GeoDataFrame
- to_healpix(nside, pass_data=True, backend='polars', polars_to_pandas=True, use_pyarrow_extension_array=False)[source]#
Convert the current polygon survey into a healpix survey.
- Parameters:
nside (int) – Healpix nside.
pass_data (bool, optional) – Should the returned survey have the full data of just the fieldid matching?
backend (str, optional) –
Which backend to use to merge the data (speed issue):
polars (fastest): requires polars installed -> converted to pandas at the end
pandas (classic): the normal way
dask (lazy): as persisted dask.dataframe is returned
polars_to_pandas (bool, optional) – = ignored if backend != ‘polars’ = Should the dataframe be converted into a pandas.DataFrame or say a polars.DataFrame (using the to_pandas() option).
use_pyarrow_extension_array (bool, optional) – = ignored in backend != ‘polars’ or polars_to_pandas is not True = Should the pandas dataframe be based on numpy array (slow to load but faster then) or based on pyarrow array (like in polars) ; faster but numpy.asarray will be used by pandas when need (which will then slow things down).
- Return type:
HealpixSurvey
- radec_to_fieldid(radec, observed_fields=False)[source]#
Get the fieldid associated to the given coordinates.
- Parameters:
radec (pandas.DataFrame or 2d array) – Coordinates in degree.
observed_fields (bool, optional) – Should this be limited to fields actually observed? This is ignored is
self.datais None.
- Return type:
pandas.DataFrame
- draw_random(size, bands, mjd_range, skynoise_range, gain_range=1, zp_range=25, inplace=False, fieldids=None, **kwargs)[source]#
Draw random observations.
- Parameters:
size (int) – number of observations to draw
mjd_range (list or array) – min and max mjd for the random drawing.
skynoise_range (list or array) – min and max skynoise for the random drawing.
gain_range (list or array) – min and max gain for the random drawing.
zp_range (list or array) – min and max zp for the random drawing.
inplace (bool) – if True, the data are stored in the instance. Otherwise, a new instance is returned.
fieldids (list) – list of fieldids to draw from.
_draw_random (**kwargs goes to)
- Return type:
PolygonSurvey or None
- show(stat='size', column=None, title=None, data=None, origin=180, vmin=None, vmax=None, cmap='tab10', autoscale=False, grid=True, **kwargs)[source]#
Show the sky coverage.
- Parameters:
stat (str, optional) – Statistic to plot.
column (str, optional) – Column to use for the statistic.
title (str, optional) – Title of the plot.
data (pandas.DataFrame, optional) – Data to plot.
origin (float, optional) – Origin of the ra coordinates.
vmin (float, optional) – Min and max values for the colorbar.
vmax (float, optional) – Min and max values for the colorbar.
cmap (str, optional) – Colormap to use.
autoscale (bool, optional) – If True, autoscale the plot.
grid (bool, optional) – If True, show the grid.
**kwargs – Goes to matplotlib.collections.PolyCollection.
- Return type:
matplotlib.figure
- property fieldids#
List of fields id.
- property nfields#
Number of fields.