Created
July 17, 2016 10:30
-
-
Save robintw/569ce05e01f405c7e9744d651123fbb6 to your computer and use it in GitHub Desktop.
Simple function to read AERONET data into a Pandas DataFrame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
def read_aeronet(filename): | |
"""Read a given AERONET AOT data file, and return it as a dataframe. | |
This returns a DataFrame containing the AERONET data, with the index | |
set to the timestamp of the AERONET observations. Rows or columns | |
consisting entirely of missing data are removed. All other columns | |
are left as-is. | |
""" | |
dateparse = lambda x: pd.datetime.strptime(x, "%d:%m:%Y %H:%M:%S") | |
aeronet = pd.read_csv(filename, skiprows=4, na_values=['N/A'], | |
parse_dates={'times':[0,1]}, | |
date_parser=dateparse) | |
aeronet = aeronet.set_index('times') | |
del aeronet['Julian_Day'] | |
# Drop any rows that are all NaN and any cols that are all NaN | |
# & then sort by the index | |
an = (aeronet.dropna(axis=1, how='all') | |
.dropna(axis=0, how='all') | |
.rename(columns={'Last_Processing_Date(dd/mm/yyyy)': 'Last_Processing_Date'}) | |
.sort_index()) | |
return an |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment