Python API
The usage of Python API is demonstrated in an example Notebook
netcdf_to_dataframe
This function queries a local or remote (via OpenDAP) NetCDF file and transform it into pandas DataFrame.
- libinsitu.common.netcdf_to_dataframe(ncfile: Union[Dataset, str], start_time: Optional[Union[datetime, datetime64]] = None, end_time: Optional[Union[datetime, datetime64]] = None, rel_start_time=None, rel_end_time=None, drop_duplicates=True, skip_na=False, skip_qc=False, vars=None, user=None, password=None, chunked=False, chunk_size=5000, steps=1, rename_cols=False)
Load NETCDF in-situ file (or part of it) into a panda Dataframe, with time as index.
- Parameters
ncfile – NetCDF Dataset or filename, or OpenDAP URL
rename_cols – If True (default) rename solar irradiance columns as per convention (GHI, BNI, DHI)
drop_duplicates – If true (default), duplicate rows are droppped
skip_qc – If True, skip lines with bad QC (at least one failing)
skip_na – If True, drop rows containing only nan values
start_time – Start time (first record by default) : Datetime or datetime64
end_time – End time (last record by default) : Datetile or datetime64
rel_end_time – End time, relative to actual start time : relativedelta
rel_start_time – Start time, relatie to actual end time : relativedelta
vars – List of columns names to convert (all by default)
user – Optional login for OpenDAP URL
password – Optional password OpenDAP URL
chunked – If True, does not load the whole file in memory at once : returns an iterator on Dataframe chunks.
chunk_size – Size of chunks for chunked data
steps – Downsampling (1 by default)
- Returns
Pandas Dataframe, or iterator on Dataframes is chunk is activated
visual_qc
This function applies QC checks on an irradiance Dataframe and output visual graphs.
- libinsitu.qc.qc_utils.visual_qc(df, latitude=None, longitude=None, elevation=None, station_id=None, station_name=None, with_horizons=False, with_mc_clear=False, show_flag=ShowFlag.SHOW, engine='matplotlib')
Generates matplotlib graphs for visual QC
- Parameters
df – Dataframe of input irradiance. It should have a time index and 3 columns : GHI, DHI, BNI). This dataframe can typically be obtained with netcdf_to_dataframe(… rename_cols=True)
latitude – Latitude of the station. Can also be passed as meta data (.attrs) of the Dataframe
longitude – Longitude of the station. Can also be passed as meta data (.attrs) of the Dataframe
elevation – elevation of the station. Can also be passed as meta data (.attrs) of the Dataframe
station_id – Id of the station (optional). Can also be passed as meta data (.attrs) of the Dataframe
station_id – Name of the station (optional). Can also be passed as meta data (.attrs) of the Dataframe
with_horizons – True to compute horizons (requires network)
with_mc_clear – True to compute mc_clear from SODA (requires SODA credentials and network access)