Skip to content

Saving data

Finally we want to save our data. To do this simply run:

data_hub.save_data()

That is the quickest way to save data. In this case it will save the outputs (that is the data, data flags, figures, pdf etc.) into a folder. The folder is named after the site (sensor_info.name) with a timestamp appended, so successive runs do not overwrite each other.

Where does it save to?

save_data() picks the output directory in this order:

  1. The save_folder_location argument, if you pass one. Relative paths resolve against the current working directory.
  2. data_storage.save_location from the sensor config — used automatically if the hub was built with DataHubFromConfig (or ProcessWithConfig) and the YAML sets it. This path is resolved to an absolute path at config-load time (see Accepted path formats below).
  3. The current working directory, as a last-resort fallback.

You can also override save_location from the command line without editing the YAML:

neptoon --sensor sensor.yaml --processing process.yaml --save-location ./output

Passing a path directly

from pathlib import Path

data_hub.save_data(
    folder_name="first_test",
    save_folder_location=Path("/path/to/save/location"),
    use_custom_column_names=False,
    custom_column_names_dict=None,
    append_timestamp=True,
)

Missing intermediate directories are created for you.

Letting the sensor config decide

If you loaded a sensor config, put the path in the YAML and save_data() will use it with no argument:

# sensor_config.yaml
data_storage:
  save_location: ./output          # relative to the config file's directory
  create_report: true
from neptoon.io.read import DataHubFromConfig

data_hub = DataHubFromConfig(sensor_config=sensor_config).create_data_hub()
# ... processing steps ...
data_hub.save_data()   # writes to <config file dir>/output

Accepted path formats for save_location

All path fields in neptoon sensor config files follow the same four-rule policy:

Input Result
blank / null Unset — cwd fallback triggers in save_data()
~/foo Expanded to the user's home directory
/abs/path Used as-is (normalised)
./rel or rel Resolved relative to the config file's directory

This applies to save_location, data_location, path_to_data, and calibration.location.