fact package¶
-
fact.
iso2dt
(iso_time_string)[source]¶ parse ISO time string to timezone aware datetime instance
example 2015-01-23T08:08+01:00
-
fact.
run2dt
(run_string)[source]¶ parse typical FACT run file path string to datetime instance (UTC)
example first you do this:
‘/path/to/file/20141231.more_text’ –> ‘20141231’ then call run2dt(‘20141231’)
Subpackages¶
Submodules¶
fact.encrypt_credentials module¶
fact.io module¶
-
fact.io.
read_data
(file_path, **kwargs)[source]¶ This is a utility wrapper for other reading functions. It will look for the file extension and try to use the correct reader and return a dataframe.
Currently supported are hdf5 (pandas and h5py), json, jsonlines and csv
Parameters: - file_path (str) – Path to the input file
- kwargs are passed to the individual reading function (All) –
- hdf5 (h5py) –
- hdf5 –
- json (pd.DataFrame(json.load(file))) –
- jsonlines (pd.read_json) –
- csv (pd.read_csv) –
-
fact.io.
read_h5py
(file_path, key='data', columns=None, mode='r+')[source]¶ Read a hdf5 file written with h5py into a dataframe
Parameters: - file_path (str) – file to read in
- key (str) – name of the hdf5 group to read in
- columns (iterable[str]) – Names of the datasets to read in. If not given read all 1d datasets
-
fact.io.
read_h5py_chunked
(file_path, key='data', columns=None, chunksize=None, mode='r+')[source]¶ Generator function to read from h5py hdf5 in chunks, returns an iterator over pandas dataframes.
When chunksize is None, use 1 chunk
-
fact.io.
check_extension
(file_path, allowed_extensions=('.hdf', '.hdf5', '.h5', '.json', '.jsonl', '.jsonlines', '.csv'))[source]¶
-
fact.io.
to_h5py
(filename, df, key='data', mode='w', dtypes=None, index=True, **kwargs)[source]¶ Write pandas dataframe to h5py style hdf5 file
Parameters: - filename (str) – output file name
- df (pd.DataFrame) – The data to write out
- key (str) – the name for the hdf5 group to hold all datasets, default: data
- mode (str) – ‘w’ to overwrite existing files, ‘a’ to append
- dtypes (dict) – if given, a mapping of column names to dtypes for conversion.
- index (bool) – If bool, also save the index of the dataframe
- **kwargs are passed to h5py.create_dataset (All) –
fact.qla module¶
-
fact.qla.
get_qla_data
(first_night=None, last_night=None, sources=None, database_engine=None)[source]¶ Request QLA results from our database
- first_night: int or None
- If given, first night to query as FACT night integer.
- last_night: int or None
- If given, last night to query as FACT night integer.
- sources: iterable[str]
- If given, only these sources will be requested. Names have to match Source.fSourceName in our db.
- database_engine: sqlalchmey.Engine
- If given, the connection to use for the query. Else, fact.credentials.create_factdb_engine will be used to create it.
fact.time module¶
some functions to deal with FACT modified modified julian date
The time used most of the time in FACT is the number of days since 01.01.1970
So this time is related to unix time, since it has the same offset (unix time is the number of seconds since 01.01.1970 (what time? noon? midnight??)) but it is also related to ‘the’ Modified Julian Date (MJD), which is used by astronomers in the sense, that it also counts days.
According to http://en.wikipedia.org/wiki/Julian_day, there is quite a large number of somehow modified julian dates, of which the MJD is only one. So it might be okay, to introduce a new modification, going by the name of FACT Julain Date (FJD).
-
fact.time.
iso2dt
(iso_time_string)[source]¶ parse ISO time string to timezone aware datetime instance
example 2015-01-23T08:08+01:00
-
fact.time.
night
(timestamp=None)[source]¶ gives the date for a day change at noon instead of midnight