Skip to content
Snippets Groups Projects
Commit 823ba89e authored by jacques.grelet_ird.fr's avatar jacques.grelet_ird.fr
Browse files

add xarray compatibility, rename dimension DEPTH to depth

parent c90807b8
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ The program works under Windows (terminal) or Git bash as well as under Linux. I
``` bash
conda create -n oceano2python python=3.9
conda activate oceano2python
conda install -c conda-forge netCDF4 toml matplotlib seawater PyInstaller pysimplegui
conda install -c conda-forge netCDF4 toml matplotlib xarray seawater PyInstaller pysimplegui
pip install julian
```
......
......@@ -13,7 +13,7 @@ def writeNetCDF(cfg, device, fe, r, variables_1D):
# variables and dimensions use for 1D and 2D variables
#variables_1D = ['TIME', 'LATITUDE', 'LONGITUDE']
variables = variables_1D.copy()
dims_2D = ['TIME', 'DEPTH']
dims_2D = ['TIME', 'depth']
# create netcdf file
fileName = "{}/OS_{}_{}.nc".format(cfg['global']
......@@ -29,7 +29,7 @@ def writeNetCDF(cfg, device, fe, r, variables_1D):
time = nc.createDimension("TIME", fe.n)
lat = nc.createDimension("LATITUDE", fe.n)
lon = nc.createDimension("LONGITUDE", fe.n)
depth = nc.createDimension('DEPTH', fe.m)
depth = nc.createDimension('depth', fe.m)
# debug
logging.debug(" depth: {}, time: {}, lat: {}, lon: {}".format(
......
# https://pumatest.nerc.ac.uk/cgi-bin/cf-checker.pl?cfversion=auto
import xarray as xr
import os
#import matplotlib.pyplot as plt
#plt.rcParams.update({'font.size': 20, 'figure.figsize': (10, 8)})
ncfiles = ['netcdf/OS_PIRATA-FR29_CTD.nc', 'netcdf/OS_PIRATA-FR29_XBT.nc','netcdf/OS_PIRATA-FR29_LADCP.nc']
for ncfile in ncfiles:
ds = xr.open_dataset(ncfile)
print(ds)
df = ds.to_dataframe()
print(df)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment