Skip to content

Functions

Cameron-Van-Eck edited this page May 31, 2022 · 5 revisions

RMTable-specific methods

All of the functions in the rmtable module are contained within the RMTable class. This class is derived from the Astropy.Table class, and inherits all of its methods and functionality. we have added some additional methods to deal with needs specific to the RMTable format; we list these below along with some of the more important inherited Astropy.Table methods:

read(filename, *args)
Pass-through function to the astropy Table reader; can read any file format accepted by that reader. Note that the default reader does not automatically identify .tsv files, so either the dedicated read function (read_tsv()) or manually setting the format keyword is needed for that format.

write(self, filename, *args
Default astropy Table writer. Can automatically identify the output format based on the file name in some cases (e.g., FITS), but requires manual setting with the format keyword for .tsv or VOtable formats. Full documentation here

input_numpy(array,verbose=False,verify=True,keep_cols=[],coordinate_system='icrs')
Creates a new rmtable from a Numpy ndarray (Numpy's version of a table).
Requires that array has named columns matching standard column names. Will automatically fill in missing columns with default values. Non-standard columns listed in keep_cols will be kept, otherwise they will be discarded.
verbose (Boolean): report missing columns
verify (Boolean): check if values conform to standard.
keep_cols (list): List of extra columns to keep.
coordinate_system (str): name of coordinate frame for ra and dec columns (typically 'fk5' or 'icrs'). If the equatorial coordinates are not in 'icrs', they will be converted to 'icrs' when building the RMTable.

read_tsv(filename, *args)
Reads .tsv files using the astropy Table reader.

write_tsv(self, filename, overwrite=False, *args)
Writes a .tsv file using the Astropy writer. A shortcut for manually setting the format keyword in the default writer function.

write_votable(self, filename, overwrite=False, *args)
Writes a VOTable (normally .xml) file using the Astropy writer. A shortcut for manually setting the format keyword in the default writer function.

verify_columns(self)
Checks that each of the standard columns is present in the table. Prints any extra or missing columns.

verify_limits(self)
Checks that each numerical (non-string) column has values within the standard range.

verify_standard_strings(self)
Checks that all string columns with lists of standardized values contain values within those lists. Note that the standardized values are intended as suggestions and are not exclusive, so this step is not required to generate a valid RMTable.

add_missing_columns(self)
Adds any columns that are part of the RMTable standard that are not present within this table. These columns are filled with the default blank values.

add_column(self,data,name,ucd=None,unit=None,*args)
Adds a new column to the RMTable, with the supplied column name and data. A UCD can optionally be specified, as well as a unit. A description of the UCD system can be found here

remove_column(self,name)
Removes the named column from the table.

convert_angles(angles)
Converts angles (either a single value or any array-like compatible with numpy) in degrees to follow the RMTable convention ([0,180) degrees). Returns array of modified angles. Useful when you have angles in the (-90,90] convention.

calculate_missing_coordinates_column(long,lat,to_galactic)
Converts a supplied set of coordinates (equatorial/ICRS or Galactic), and supplies the corresponding set. The to_galactic keyword (boolean) specifies if the conversion should be from ICRS to Galactic (True) or from Galactic to ICRS (False). This is used internally by from_numpy() to add a missing set of coordinates if necessary. Returns the new set of coordinate arrays (does not automatically add them as columns).

RMTable class data attributes:

Each RMTable has the following attribute variables defined (in approximate order of relevance to the user):

dtype: a list of the data types for each column present in the table.
size: integer giving the number of rows present in the table.
standard_columns: list of the names of the default columns in the RMTable standard.
standard_dtypes: list of the data types of the default columns in the RMTable standard.
standard_limits: list of the value limits (lower and upper bounds, as a 2-element list per column) for each default column in the RMTable standard (string columns have only an empty string).
standard_blanks: list of default values for missing data, for the default columns in the RMTable standard.
standard_rm_method, standard_pol_bias, standard_telescope, standard_classification, standard_flux_type, standard_complexity_test, standard_ionosphere: lists of string values for each corresponding column that are considered standard values.
ucds: a dictionary of the UCD for each column.
units: a dictionary of the units for each column.

Clone this wiki locally