The Ocean Navigator is an online tool that is used to help visualise scientific research data. a users guide is available at https://dfo-ocean-navigator.github.io/Ocean-Navigator-Manual/ and the tool is live at
This pull request addresses the need to import data from NetCDF files from cmems into a database using Python. The code leverages the xarray library to handle NetCDF files and SQLAlchemy for database operations. The script aims to provide a flexible and efficient solution for importing observational data into a database.
Why did you take this approach?
Database operations are optimized by using SQLAlchemy's session management. Sessions are committed after each step to minimize the risk of data loss in case of failures.
To import data from NetCDF files from cmems into a database using Python.
Anything in particular that should be highlighted?
The script iterates over each NetCDF file, extracting relevant data variables defined in the VARIABLE_MAPPING. It then iterates over the rows of the DataFrame to create corresponding database records for stations, samples, data types, and platforms.
Users can specify the database URI as an input parameter, allowing them to connect to different databases without modifying the code.
The defopt library is utilized to automatically generate a CLI for the script, simplifying its invocation and usage. Users can run the script from the command line with minimal effort.
Screenshot(s)
Checks
[x] I ran unit tests.
[x] I've tested the relevant changes from a user POV.
[x] I've formatted my Python code using black ..
Hint To run all python unit tests run the following command from the root repository directory:
Background
This pull request addresses the need to import data from NetCDF files from cmems into a database using Python. The code leverages the xarray library to handle NetCDF files and SQLAlchemy for database operations. The script aims to provide a flexible and efficient solution for importing observational data into a database.
Why did you take this approach?
Anything in particular that should be highlighted?
Screenshot(s)
Checks
black .
.Hint To run all python unit tests run the following command from the root repository directory: