API documentation

korexo_profile.read(fn, encoding='utf-16', parse_dts=True, datefmt='auto', auto_revert_encoding='cp1252')[source]

Read KorEXO sonde profile.

  • fn (str) – filename

  • encoding (str) – file encoding. I believe raw KorEXO output is in UTF-16.

  • parse_dts (bool) – whether to attempt to parse datetimes or not.

  • datefmt (str) – use “auto” to use the column header to infer the date format, although note that this isn’t always correct. In that case, set it here using Python datetime string formats e.g. "%d/%m/%Y"

  • auto_revert_encoding (str or None/False) – attempt to check whether the file is UTF-16 and if it is not i.e. there is no BOM, then use whatever encoding is set here. Set to False only if you want the code to attempt encoding and fail messily if it is not.


with keys ‘metadata’, ‘dataframe’ and ‘datasets’. See package documentation for more details.

Return type:


korexo_profile.convert_datasets_to_df(datasets, mapping={'Battery V': 'battery', 'Cable Pwr V': 'cable_power', 'Cond µS/cm': 'cond', 'Date (DD/MM/YYYY)': 'date', 'Date (MM/DD/YYYY)': 'date', 'Depth m': 'water_depth', 'ODO % local': 'do_local', 'ODO % sat': 'do_sat', 'ODO mg/L': 'do_conc', 'ORP mV': 'orp_mv', 'Pressure psi a': 'press', 'Sal psu': 'sal_psu', 'Site Name': 'site', 'SpCond µS/cm': 'spcond', 'TDS mg/L': 'tds', 'Temp °C': 'temp', 'Time (Fract. Sec)': 'time_sec', 'Time (HH:mm:ss)': 'time', 'Vertical Position m': 'vert_pos', 'nLF Cond µS/cm': 'cond_nlf', 'pH': 'ph', 'pH mV': 'ph_mv'})[source]

Convert a list of datasets to a dataframe, include renaming of column names if desired.

  • datasets (list) – see output of korexo_profile.read().

  • mapping (dict) – optional. The default mapping is stored in korexo_profile.COL_MAPPING


dataframe with “datetime” column added.

Return type:


korexo_profile.make_regularly_spaced(df, index_col='dtw', step=0.05, step_precision=5)[source]

Convert dataframe to regular spacing based on an index column.

  • df (pandas DataFrame) –

  • index_col (str) – column of df for which a regularly-spaced set of values should be created at step and then all other data interpolated against.

  • step (float) – interval desired in index_col

  • step_precision (int) –


dataframe, where the newly created index_col values are set as the dataframe index. All other columns of df are included as columns of the df, interpolated at the new index_col values.

Return type:


korexo_profile.to_las(df, fn, encoding='utf-16', col_metadata=None, well_metadata=None, param_metadata=None, add_mtime_date='DATE', auto_revert_encoding='cp1252')[source]

Convert a KorEXO profile file to Log ASCII Standard (LAS).

  • df (pandas DataFrame) – a regularly-spaced output from reading a KorEXO profile CSV file.

  • fn (str) – the original CSV file

  • col_metadata (dict) – optional metadata for the columns. The keys should refer to columns of df and each value should be a tuple. The first item of the tuple is a string for the unit e.g. "m", and the second item is the description.

  • well_metadata (dict) – dict of metadata to add to the LAS file’s ~Well section.

  • param_metadata (dict) – dict of metadata to add to the LAS file’s ~Param section

  • add_mtime_date (str) – add the file modified time of fn as a value in the ~Well section. Set to False or None to prevent adding it at all.

  • auto_revert_encoding (bool) – attempt to check whether the file is UTF-16 and if it is not i.e. there is no BOM, then use this encoding instead. Set to False only if you want the code to fail messily if you have the encoding wrong.


lasio.LASFile object

The contents of the original KorEXO profile CSV file will be recorded in the LAS file’s ~Other block.


>>> import korexo_profile
>>> data = korexo_profile.read(fn, datefmt="%d/%m/%Y")
>>> df = korexo_profile.convert_datasets_to_df(data["datasets"])
>>> df["water_depth"] += WELL_DEPTH_TO_WATER_MEASUREMENT
>>> df2 = korexo_profile.make_regularly_spaced(df, "water_depth", step=0.05)
>>> las = korexo_profile.to_las(df2, fn)