MESSENGERdata

MESSENGER UVVS data class

exception MESSENGERuvvs.MESSENGERdata.InputError(expression, message)[source]

Raised when a required parameter is not included in the inputfile.

class MESSENGERuvvs.MESSENGERdata.MESSENGERdata(species=None, comparisons=None)[source]

Retrieve MESSENGER data from database. Given a species and set of comparisons, retrieve MESSSENGER UVVS data from the database. The list of searchable fields is given at Database Fields Used by MESSENGERuvvs.

Returns a MESSENGERdata Object.

Parameters

species

Species to search. This is required because the data from each species is stored in a different database table.

query

A SQL-style list of comparisons.

The data in the object created is extracted from the database tables using the query:

SELECT *
FROM <species>uvvsdata, <species>pointing
WHERE <query>

See examples below.

Class Atributes

species

The object can only contain a single species.

frame

Coordinate frame for the data, either MSO or Model.

query

SQL query used to search the database and create the object.

data

Pandas dataframe containing result of SQL query. Columns in the dataframe are the same as in the database except frame and species have been dropped as they are redundant. If models have been run, there are also columns in the form modelN for the Nth model run.

taa

Median true anomaly for the data in radians.

model_label

If N models have been run, this is a dictionary in the form {'model0':label0, ..., 'modelN':labelN} containing descriptions for the models.

model_strength

If N models have been run, this is a dictionary in the form {'model0':strength0, ..., 'modelN':strengthN} containing modeled source rates in units of 10^{26} atoms/s.

Examples

  1. Loading data

>>> from MESSENGERuvvs import MESSENGERdata

>>> CaData = MESSENGERdata('Ca', 'orbit = 36')

>>> print(CaData)
Species: Ca
Query: orbit = 36
Frame: MSO
Object contains 581 spectra.

>>> NaData = MESSENGERdata('Na', 'orbit > 100 and orbit < 110')

>>> print(NaData)
Species: Na
Query: orbit > 100 and orbit < 110
Frame: MSO
Object contains 3051 spectra.

>>> MgData = MESSENGERdata('Mg',
        'loctimetan > 5.5 and loctimetan < 6.5 and alttan < 1000')

>>> print(len(MgData))
45766
  1. Accessing data.

  • The observations are stored within the MESSENGERdata object in a pandas dataframe attribute called data. Please see the pandas documentation for more information on how to work with dataframes.

>>> print(CaData.data.head(5))
                         utc  orbit  merc_year  ...  loctimetan         slit               utcstr
unum                                            ...
3329 2011-04-04 21:24:11.820     36          0  ...   14.661961  Atmospheric  2011-04-04T21:24:11
3330 2011-04-04 21:25:08.820     36          0  ...   12.952645  Atmospheric  2011-04-04T21:25:08
3331 2011-04-04 21:26:05.820     36          0  ...   12.015670  Atmospheric  2011-04-04T21:26:05
3332 2011-04-04 21:27:02.820     36          0  ...   12.007919  Atmospheric  2011-04-04T21:27:02
3333 2011-04-04 21:27:59.820     36          0  ...   12.008750  Atmospheric  2011-04-04T21:27:59

[5 rows x 29 columns]
  • Individual observations can be extracted using standard Python slicing techniques:

>>> print(CaData[3:8])
Species: Ca
Query: orbit = 36
Frame: MSO
Object contains 5 spectra.

>>> print(CaData[3:8].data['taa'])
unum
3332    1.808107
3333    1.808152
3334    1.808198
3335    1.808243
3336    1.808290
Name: taa, dtype: float64
  1. Modeling data

>>> inputs = Input('Ca.spot.Maxwellian.input')
>>> CaData.model(inputs, 1e5, label='Model 1')
>>> inputs..speeddist.temperature /= 2.  # Run model with different temperature
>>> CaData.model(inputs, 1e5, label='Model 2')
  1. Plotting data

>>> CaData.plot('Ca.orbit36.models.html')
  1. Exporting data to a file

>>> CaData.export('modelresults.csv')
>>> CaData.export('modelresults.html', columns=['taa'])
export(self, filename, columns=['utc', 'radiance'])[source]

Export data and models to a file. Parameters

filename

Filename to export model results to. The file extension determines the format. Formats available: csv, pkl, html, tex

columns

Columns from the data dataframe to export. Available columns can be found by calling the keys() method on the data object. Default = [‘utc’, ‘radiance’] and all model result columns. Note: The default columns are always included in the output regardless of whether they are specified.

Returns

No outputs.

keys(self)[source]

Return all keys in the object, including dataframe columns

set_frame(self, frame=None)[source]

Convert between MSO and Model frames.

More frames could be added if necessary. If Frame is not specified, flips between MSO and Model.