survey.core#
This module defines the BaseSurvey base class, providing the core data structure and shared methods for all survey types.
- class skysurvey.survey.core.BaseSurvey(data)[source]#
Bases:
objectThe BaseSurvey class.
- Parameters:
data (pandas.DataFrame) – observing data.
REQUIRED_COLUMNS (list) –
List of column names that must be present in the input DataFrame:
mjd: Modified Julian Date of the observation.band: Filter/bandpass used (e.g., ‘g’, ‘r’, ‘i’).skynoise: Image background contribution to flux error.gain: CCD gain (e.g., electrons/ADU).zp: Photometric zeropoint.
- set_data(data, lower_precision=True, sort_mjd=True)[source]#
Set the observing data.
= It is unlikely you need to use that directly. =
- get_timerange(timekey='mjd')[source]#
Returns the min and max of the given timekey column.
- Parameters:
timekey (str) – column name of the time column.
- Return type:
numpy.array
- get_fieldcoverage(incl_zeros=False, fillna=nan, **kwargs)[source]#
Short cut to
get_fieldstat('size').- Parameters:
- Returns:
following groupby.agg()
- Return type:
DataFrame or Serie
See also
get_fieldstat: get observing statistics for the fields
- get_fieldstat(stat, columns=None, incl_zeros=False, fillna=nan, data=None)[source]#
Get observing statistics for the fields.
basically a shortcut to
data.groupby("fieldid")[`column`].`stat`()- Parameters:
stat (str, list) – element to be passed to groupby.agg() could be e.g.: ‘mean’ or [‘mean’, ‘std’] or [np.median, ‘mean’] etc. If stat = ‘size’, this returns data[“fieldid”].value_counts() (slightly faster than groupby(“fieldid”).size()).
columns (str, list, None) – name of the columns to be kept. None means no cut.
incl_zeros (bool) – fields will no entries will not be shown except if incl_zeros is True
data (pandas.DataFrame, None) – data you want this to be applied to. if None, a copy of self.data is used. = leave to None if unsure =
- Returns:
following groupby.agg()
- Return type:
DataFrame or Serie
- radec_to_fieldid(radec)[source]#
Get the fieldid of the given (list of) coordinates.
- Parameters:
radec (pandas.DataFrame or 2d array) – coordinates in degree
- Return type:
pandas.Series
- get_observations_from_coords(radec)[source]#
Returns the data associated to the input radec coordinates.
(calls
radec_to_fieldidand select data matching the fieldid)- Parameters:
radec (pandas.DataFrame or 2d array) – coordinates in degree (see format
radec_to_fieldid())- Returns:
copy of the data observed in the given radec coordinates
- Return type:
pandas.DataFrame
- show()[source]#
Shows the sky coverage.
- Raises:
NotImplementedError – This method is not implemented for this survey.
- show_nexposures(ax=None, exposure_key='expid', bands=None, perband=True, band_key='band', band_colors=None, fieldid=None, legend=True, **kwargs)[source]#
Show the number of exposures per day.
- Parameters:
ax (matplotlib.axes) – axes to plot on.
exposure_key (str) – column name of the exposure id.
bands (list) – list of bands to plot.
perband (bool) – if True, plot the number of exposures per band.
band_key (str) – column name of the band.
band_colors (dict) – dictionary of colors for each band.
legend (bool) – if True, show the legend.
ax.bar (**kwargs goes to)
- Return type:
matplotlib.figure
- property data#
Dataframe containing what has been observed when. aka. the observing data
- property metadata#
Metadata associated to the survey,
- property nfields#
Number of fields
- property fields#
Geodataframe containing the fields coordinates.
- property of_type#
Kind of survey that is.
- property date_range#
First and last date of the survey.