keteutils.fov.FOVCollection
keteutils.fov.FOVCollection(fovs, fov_desigs=None, sort_fovlist=False)A convenience tool for FOVList
It allows (fovc = FOVCollection(fovs)):
- Easy indexing like numpy (e.g.,
fovc[0]orfovc[1:10]), - Easy masking (e.g.,
fovc[mask_arr]), - Easy access to FOV designations (e.g.,
fovc["fov001"]) - Easy access by multiple designations (e.g.,
fovc[["fov001", "fov002"]]).
Has useful methods/attributes:
.fov_jds: An array of JDs for the FOVs (must be in TDB)..mask_by_desig(desigs): Returns a mask for the FOVs based on the designations. Very fast because it usessetbehind the curtains.- Use the resulting mask as
fovc[mask]to get the subset of FOVs in ndarray. - Use
fovc.fov_desigs[mask]to get the corresponding designations in ndarray. - Make a new collection object by
FOVCollection(fovc[mask]).
- Use the resulting mask as
Methods
| Name | Description |
|---|---|
| init | |
| fov_jds_by_desig | Return an array of JDs for the FOVs (must be in TDB). |
| mask_by_desig | Return a mask for the FOVs based on the designations. |
| save | Save the FOVCollection to a Parquet file. |
| load | Load a FOVCollection saved by FOVCollection.save. |
init
keteutils.fov.FOVCollection.__init__(fovs, fov_desigs=None, sort_fovlist=False)Parameters
fovs :kete.FOVor iterable ofkete.FOV-
An iterable of FOV objects, or a
kete.FOVListobject. fov_desigs : array-like of str, default = None-
A list of designations for the FOVs. If not provided, the designations will be taken from the
observer.desigof each FOV. Note that kete never allows non-strdesigfor observerState, so it is expected the givenfov_desigsare strings. sort_fovlist : bool, default = False-
If
True, the FOVs will be sorted by JD (kete.fov.FOVList.sort()).
fov_jds_by_desig
keteutils.fov.FOVCollection.fov_jds_by_desig(desigs=None)Return an array of JDs for the FOVs (must be in TDB).
Parameters
desigs : str or iterable of str, default = None-
A single designation or an iterable of designations to filter the JDs. If provided, it overrides
mask. Ifdesigsis None, return all JDs (identical toself.fov_jds).
mask_by_desig
Return a mask for the FOVs based on the designations.
Parameters
desigs : str or iterable of str-
A single designation or an iterable of designations to mask the FOVs.
Returns
fovmask : np.ndarray of bool-
A boolean mask indicating which FOVs have the given designations.
Notes
It will be faster than simple FOVCollection.fov_desigs.isin(desigs) or [FOVCollection[desig] for desig in desigs] because it uses set behind the curtains. For example, this method is about 10x faster than these alternatives for ~1000 FOV elements.
save
keteutils.fov.FOVCollection.save(filename, overwrite=False, compression='zstd')Save the FOVCollection to a Parquet file.
Parameters
filename : str or Path-
Path of the Parquet file.
overwrite : bool, default = False-
If True, overwrite the existing file. If False (default), raises FileExistsError if the file already exists.
compression : str, default = 'zstd'-
The compression to use for saving the parquet file (see
pyarrow.parquet.write_tablefor details). Default is"zstd".
Raises
: TypeError-
If a FOV is not a
kete.ConeFOV,kete.RectangleFOV, orkete.OmniDirectionalFOV.
Notes
The file has one row per FOV and does not depend on the kete version. All vectors are in the ecliptic frame, one float64 column per component:
desig(str):fov_desigs.fov_type(str):"cone","rectangle", or"omni".obs_desig(str),obs_jd(TDB JD),obs_center(int64, NAIF ID of the observer state center).obs_x,obs_y,obs_z(au) andobs_vx,obs_vy,obs_vz(au/day): observer state.pointing_x,pointing_y,pointing_z: FOV center direction. NaN for"omni".angle(deg): cone radius. NaN unless"cone".corner{0-3}_{x,y,z}: rectangle corner directions. NaN unless"rectangle".
The file metadata skyloc.fov.frame is ecliptic.
load
keteutils.fov.FOVCollection.load(filename, filters=None)Load a FOVCollection saved by FOVCollection.save.
Parameters
filename : str or Path-
Path of the Parquet file.
filters : str, list, or None, default = None-
Row filter passed to
pqfilt.read, e.g.,"obs_jd > 2461200.5"or"desig in fov001,fov002". Default isNone(all rows).
Returns
: FOVCollection-
A new FOVCollection with the saved FOVs and
fov_desigs.
Raises
: ValueError-
If a Parquet file does not have the columns and the frame metadata that
FOVCollection.savewrites.
Notes
With kete_ipac (v1.x), a file written by kete.fov.FOVList.save (not Parquet) is also read, and filters must be None for it.