User Tools

Site Tools


data:data_analysis_manual:read_catalog_python

**This is an old revision of the document!**

How to read the UiO FITS files catalog in Python

read_uio_cat.py
from pathlib import Path
import pandas as pd
 
# SPICE data tree path, to be changed to your SPICE data mirror
data_path = "/archive/SOLAR-ORBITER/SPICE"      # example for IAS computing servers
 
def read_uio_cat():
    """
    Read UiO text table SPICE FITS files catalog
    http://astro-sdc-db.uio.no/vol/spice/fits/spice_catalog.txt
 
    Return
    ------
    pandas.DataFrame
        Table
 
    Example queries that can be done on the result:
 
    * `df[(df.LEVEL == "L2") & (df["DATE-BEG"] >= "2020-11-17") & (df["DATE-BEG"] < "2020-11-18") & (df.XPOSURE > 60.)]`
    * `df[(df.LEVEL == "L2") & (df.STUDYDES == "Standard dark for cruise phase")]`
    """
    cat_file = Path(data_path) / "fits" / "spice_catalog.txt"
    columns = list(pd.read_csv(cat_file, nrows=0).keys())
    date_columns = ['DATE-BEG','DATE', 'TIMAQUTC']
    df = pd.read_table(cat_file, skiprows=1, names=columns, na_values="MISSING",
                    parse_dates=date_columns, warn_bad_lines=True)
    df.LEVEL = df.LEVEL.apply(lambda string: string.strip())
    df.STUDYTYP = df.STUDYTYP.apply(lambda string: string.strip())
    return df

na_values=“MISSING” replaces the string “MISSING” by NaNs, it can be removed.

data/data_analysis_manual/read_catalog_python.1625043282.txt.gz · Last modified: 2021/06/30 10:54 by eric buchlin