Skip to content
Snippets Groups Projects
Commit 8acf6806 authored by Boshra Ariguib's avatar Boshra Ariguib
Browse files

added temperature plot

parent 31b5f944
Branches
No related tags found
No related merge requests found
%% Cell type:markdown id: tags:
# Implement the MLP from the Paper
%% Cell type:markdown id: tags:
### Imports
%% Cell type:code id: tags:
``` python
import numpy as np
import torch
import matplotlib as plt
import matplotlib.pyplot as plt
from scipy.io import netcdf
import os
import pandas as pd
import xarray as xr
```
%% Cell type:markdown id: tags:
### Load the Data
%% Cell type:markdown id: tags:
Load data using ``xarray`` library
%% Cell type:code id: tags:
``` python
ds = xr.open_dataset('./dataset/LD_1900973.nc')
ds
```
%% Output
<xarray.Dataset> Size: 18kB
Dimensions: (N_PROF: 1, N_LEVELS: 72, N_LEVELS_2: 200)
Dimensions without coordinates: N_PROF, N_LEVELS, N_LEVELS_2
Data variables: (12/28)
ID (N_PROF) float64 8B ...
PARAM (N_PROF) |S1 1B ...
LON (N_PROF) float64 8B ...
LAT (N_PROF) float64 8B ...
POS_QC (N_PROF) float64 8B ...
BAT (N_PROF) float64 8B ...
... ...
PSAL_MEDs (N_PROF, N_LEVELS_2) float64 2kB ...
PSAL_MINs (N_PROF, N_LEVELS_2) float64 2kB ...
PSAL_MAXs (N_PROF, N_LEVELS_2) float64 2kB ...
TEMP_MEDs (N_PROF, N_LEVELS_2) float64 2kB ...
TEMP_MINs (N_PROF, N_LEVELS_2) float64 2kB ...
TEMP_MAXs (N_PROF, N_LEVELS_2) float64 2kB ...
%% Cell type:markdown id: tags:
Plot the temperature
%% Cell type:code id: tags:
``` python
TEMP_ar = np.array(ds['TEMP'])
plt.plot(TEMP_ar.flatten())
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
df = pd.DataFrame()
df.columns = ['ID', 'PARAM', 'LON', 'LAT', 'POS_QC', 'BAT', 'JULD', 'JULD_QC', 'FALSEorTRUE', 'PRES', 'PRES_QC', 'PSAL', 'PSAL_QC', 'PSAL_MED', 'PSAL_MIN', 'PSAL_MAX', 'TEMP', 'TEMP_QC', 'TEMP_MED', 'TEMP_MIN', 'TEMP_MAX', 'PRESs', 'PSAL_MEDs', 'PSAL_MINs', 'PSAL_MAXs', 'TEMP_MEDs', 'TEMP_MINs', 'TEMP_MAXs']
data = []
labels = ['ID', 'PARAM', 'LON', 'LAT', 'POS_QC', 'BAT', 'JULD', 'JULD_QC', 'FALSEorTRUE', 'PRES', 'PRES_QC', 'PSAL', 'PSAL_QC', 'PSAL_MED', 'PSAL_MIN', 'PSAL_MAX', 'TEMP', 'TEMP_QC', 'TEMP_MED', 'TEMP_MIN', 'TEMP_MAX', 'PRESs', 'PSAL_MEDs', 'PSAL_MINs', 'PSAL_MAXs', 'TEMP_MEDs', 'TEMP_MINs', 'TEMP_MAXs']
for filename in os.listdir("./dataset"):
file2read = netcdf.NetCDFFile("./dataset/"+filename, 'r')
print("\n".join(str(file2read.variables).split(',')))
labels = file2read.variables.keys()
break
#data.append(temp[:]*1)
#file2read.close()
```
%% Output
{'ID': <scipy.io._netcdf.netcdf_variable object at 0x7498851db4d0>
'PARAM': <scipy.io._netcdf.netcdf_variable object at 0x7498851db490>
'LON': <scipy.io._netcdf.netcdf_variable object at 0x7498851db5d0>
'LAT': <scipy.io._netcdf.netcdf_variable object at 0x7498851db6d0>
'POS_QC': <scipy.io._netcdf.netcdf_variable object at 0x7498851db7d0>
'BAT': <scipy.io._netcdf.netcdf_variable object at 0x7498851db8d0>
'JULD': <scipy.io._netcdf.netcdf_variable object at 0x7498851db9d0>
'JULD_QC': <scipy.io._netcdf.netcdf_variable object at 0x7498851dbad0>
'FALSEorTRUE': <scipy.io._netcdf.netcdf_variable object at 0x7498851dbbd0>
'PRES': <scipy.io._netcdf.netcdf_variable object at 0x7498851dbcd0>
'PRES_QC': <scipy.io._netcdf.netcdf_variable object at 0x7498851dbdd0>
'PSAL': <scipy.io._netcdf.netcdf_variable object at 0x7498851dbed0>
'PSAL_QC': <scipy.io._netcdf.netcdf_variable object at 0x7498851dbfd0>
'PSAL_MED': <scipy.io._netcdf.netcdf_variable object at 0x7498851daed0>
'PSAL_MIN': <scipy.io._netcdf.netcdf_variable object at 0x7498851dacd0>
'PSAL_MAX': <scipy.io._netcdf.netcdf_variable object at 0x7498851daad0>
'TEMP': <scipy.io._netcdf.netcdf_variable object at 0x7498851da8d0>
'TEMP_QC': <scipy.io._netcdf.netcdf_variable object at 0x7498851da6d0>
'TEMP_MED': <scipy.io._netcdf.netcdf_variable object at 0x7498851da4d0>
'TEMP_MIN': <scipy.io._netcdf.netcdf_variable object at 0x7498851da2d0>
'TEMP_MAX': <scipy.io._netcdf.netcdf_variable object at 0x7498851da0d0>
'PRESs': <scipy.io._netcdf.netcdf_variable object at 0x7498851d9ed0>
'PSAL_MEDs': <scipy.io._netcdf.netcdf_variable object at 0x7498851d9d90>
'PSAL_MINs': <scipy.io._netcdf.netcdf_variable object at 0x7498851d9c90>
'PSAL_MAXs': <scipy.io._netcdf.netcdf_variable object at 0x7498851d9b90>
'TEMP_MEDs': <scipy.io._netcdf.netcdf_variable object at 0x7498851d9a90>
'TEMP_MINs': <scipy.io._netcdf.netcdf_variable object at 0x7498851d9a50>
'TEMP_MAXs': <scipy.io._netcdf.netcdf_variable object at 0x7498851dd2d0>}
dict_keys(['ID', 'PARAM', 'LON', 'LAT', 'POS_QC', 'BAT', 'JULD', 'JULD_QC', 'FALSEorTRUE', 'PRES', 'PRES_QC', 'PSAL', 'PSAL_QC', 'PSAL_MED', 'PSAL_MIN', 'PSAL_MAX', 'TEMP', 'TEMP_QC', 'TEMP_MED', 'TEMP_MIN', 'TEMP_MAX', 'PRESs', 'PSAL_MEDs', 'PSAL_MINs', 'PSAL_MAXs', 'TEMP_MEDs', 'TEMP_MINs', 'TEMP_MAXs'])
/tmp/ipykernel_190732/2198214053.py:4: DeprecationWarning: `scipy.io.netcdf.NetCDFFile` is deprecated along with the `scipy.io.netcdf` namespace. `scipy.io.netcdf.NetCDFFile` will be removed in SciPy 1.14.0, and the `scipy.io.netcdf` namespace will be removed in SciPy 2.0.0.
file2read = netcdf.NetCDFFile("./Dataset/"+filename, 'r')
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[3], line 2
1 df = pd.DataFrame()
----> 2 df.columns = ['ID', 'PARAM', 'LON', 'LAT', 'POS_QC', 'BAT', 'JULD', 'JULD_QC', 'FALSEorTRUE', 'PRES', 'PRES_QC', 'PSAL', 'PSAL_QC', 'PSAL_MED', 'PSAL_MIN', 'PSAL_MAX', 'TEMP', 'TEMP_QC', 'TEMP_MED', 'TEMP_MIN', 'TEMP_MAX', 'PRESs', 'PSAL_MEDs', 'PSAL_MINs', 'PSAL_MAXs', 'TEMP_MEDs', 'TEMP_MINs', 'TEMP_MAXs']
3 data = []
4 labels = ['ID', 'PARAM', 'LON', 'LAT', 'POS_QC', 'BAT', 'JULD', 'JULD_QC', 'FALSEorTRUE', 'PRES', 'PRES_QC', 'PSAL', 'PSAL_QC', 'PSAL_MED', 'PSAL_MIN', 'PSAL_MAX', 'TEMP', 'TEMP_QC', 'TEMP_MED', 'TEMP_MIN', 'TEMP_MAX', 'PRESs', 'PSAL_MEDs', 'PSAL_MINs', 'PSAL_MAXs', 'TEMP_MEDs', 'TEMP_MINs', 'TEMP_MAXs']
File ~/.venv/lib/python3.10/site-packages/pandas/core/generic.py:6310, in NDFrame.__setattr__(self, name, value)
6308 try:
6309 object.__getattribute__(self, name)
-> 6310 return object.__setattr__(self, name, value)
6311 except AttributeError:
6312 pass
File properties.pyx:69, in pandas._libs.properties.AxisProperty.__set__()
File ~/.venv/lib/python3.10/site-packages/pandas/core/generic.py:813, in NDFrame._set_axis(self, axis, labels)
808 """
809 This is called from the cython code when we set the `index` attribute
810 directly, e.g. `series.index = [1, 2, 3]`.
811 """
812 labels = ensure_index(labels)
--> 813 self._mgr.set_axis(axis, labels)
814 self._clear_item_cache()
File ~/.venv/lib/python3.10/site-packages/pandas/core/internals/managers.py:238, in BaseBlockManager.set_axis(self, axis, new_labels)
236 def set_axis(self, axis: AxisInt, new_labels: Index) -> None:
237 # Caller is responsible for ensuring we have an Index object.
--> 238 self._validate_set_axis(axis, new_labels)
239 self.axes[axis] = new_labels
File ~/.venv/lib/python3.10/site-packages/pandas/core/internals/base.py:98, in DataManager._validate_set_axis(self, axis, new_labels)
95 pass
97 elif new_len != old_len:
---> 98 raise ValueError(
99 f"Length mismatch: Expected axis has {old_len} elements, new "
100 f"values have {new_len} elements"
101 )
ValueError: Length mismatch: Expected axis has 0 elements, new values have 28 elements
%% Cell type:code id: tags:
``` python
data = []
for filename in os.listdir("./dataset"):
data_dict = {}
file = netcdf.NetCDFFile("./dataset/"+filename, 'r')
for key in file.variables.keys():
print(str(key)+str(file.variables[key].shape))
array1 = np.array(file.variables[key][:])
print(array1)
break
```
%% Output
ID(10,)
[4902348. 4902348. 4902348. 4902348. 4902348. 4902348. 4902348. 4902348.
4902348. 4902348.]
PARAM(10,)
[b'S' b'S' b'S' b'S' b'S' b'S' b'S' b'T' b'T' b'T']
LON(10,)
[-63.30220032 -65.82562256 -66.58381653 -66.03295898 -62.81240845
-61.54801178 -62.60052872 -60.74716187 -58.60076141 -56.67736816]
LAT(10,)
[39.2846489 38.96775818 38.944561 39.08074188 38.42969894 40.25947189
39.88175964 37.27618027 38.27209854 40.98376846]
POS_QC(10,)
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
BAT(10,)
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
JULD(10,)
[737242.99222222 737252.83219907 737262.70913194 737272.50612269
737282.36993056 737292.2512963 737302.10585648 737311.97128472
737321.80684028 737331.68841435]
JULD_QC(10,)
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
FALSEorTRUE(10,)
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
PRES(10, 1023)
[[4.79999989e-01 1.08000004e+00 2.00000000e+00 ... nan
nan nan]
[4.00000006e-01 1.03999996e+00 2.03999996e+00 ... 2.03016003e+03
nan nan]
[4.79999989e-01 1.03999996e+00 2.00000000e+00 ... 2.03000000e+03
2.03219995e+03 2.03304004e+03]
...
[1.00000000e+00 2.00000000e+00 3.03999996e+00 ... nan
nan nan]
[9.20000017e-01 1.96000004e+00 3.03999996e+00 ... nan
nan nan]
[9.59999979e-01 1.91999996e+00 2.96000004e+00 ... nan
nan nan]]
PRES_QC(10, 1023)
[[1. 1. 1. ... 9. 9. 9.]
[1. 1. 1. ... 1. 9. 9.]
[1. 1. 1. ... 1. 1. 1.]
...
[1. 1. 1. ... 9. 9. 9.]
[1. 1. 1. ... 9. 9. 9.]
[1. 1. 1. ... 9. 9. 9.]]
PSAL(10, 1023)
[[35.7179985 35.71300125 35.7140007 ... nan nan
nan]
[34.77999878 34.78099823 34.79100037 ... 34.72200012 nan
nan]
[34.78099823 34.78699875 34.79299927 ... 34.73099899 34.73099899
34.72999954]
...
[35.88800049 35.88600159 35.88600159 ... nan nan
nan]
[36.25099945 36.25099945 36.25099945 ... nan nan
nan]
[36.31600189 36.31499863 36.31499863 ... nan nan
nan]]
PSAL_QC(10, 1023)
[[4. 4. 4. ... 9. 9. 9.]
[4. 4. 4. ... 4. 9. 9.]
[4. 4. 4. ... 4. 4. 4.]
...
[4. 4. 4. ... 9. 9. 9.]
[4. 4. 4. ... 9. 9. 9.]
[4. 4. 4. ... 9. 9. 9.]]
PSAL_MED(10, 1023)
[[36.188999 36.188999 36.188999 ... nan nan nan]
[35.796001 35.796001 35.796001 ... 34.945801 nan nan]
[35.796001 35.796001 35.796001 ... 34.945801 34.945801 34.945801 ]
...
[36.3145925 36.3145925 36.3145925 ... nan nan nan]
[36.3855 36.3855 36.3855 ... nan nan nan]
[35.993 35.993 35.993 ... nan nan nan]]
PSAL_MIN(10, 1023)
[[34.314999 34.314999 34.314999 ... nan nan nan]
[32.966 32.966 32.966 ... 34.932999 nan nan]
[32.966 32.966 32.966 ... 34.932999 34.932999 34.932999]
...
[35.266998 35.266998 35.266998 ... nan nan nan]
[34.800098 34.800098 34.800098 ... nan nan nan]
[33.67799 33.67799 33.67799 ... nan nan nan]]
PSAL_MAX(10, 1023)
[[36.653099 36.653099 36.653099 ... nan nan nan]
[36.662998 36.662998 36.662998 ... 34.981998 nan nan]
[36.662998 36.662998 36.662998 ... 34.981998 34.981998 34.981998]
...
[36.606998 36.606998 36.606998 ... nan nan nan]
[36.623009 36.623009 36.623009 ... nan nan nan]
[36.659 36.659 36.659 ... nan nan nan]]
TEMP(10, 1023)
[[27.09799957 27.10400009 27.10400009 ... nan nan
nan]
[24.67399979 24.67499924 24.68099976 ... 3.81399989 nan
nan]
[24.49500084 24.49900055 24.5 ... 3.93099999 3.93099999
3.93099999]
...
[27.95599937 27.96100044 27.95999908 ... nan nan
nan]
[28.00900078 28.00900078 28.00499916 ... nan nan
nan]
[27.01099968 27.01099968 27.01099968 ... nan nan
nan]]
TEMP_QC(10, 1023)
[[4. 4. 4. ... 9. 9. 9.]
[4. 4. 4. ... 4. 9. 9.]
[4. 4. 4. ... 4. 4. 4.]
...
[4. 4. 4. ... 9. 9. 9.]
[4. 4. 4. ... 9. 9. 9.]
[4. 4. 4. ... 9. 9. 9.]]
TEMP_MED(10, 1023)
[[23.509001 23.509001 23.509001 ... nan nan nan]
[20.3086005 20.3086005 20.3086005 ... 3.408 nan nan]
[20.3086005 20.3086005 20.3086005 ... 3.408 3.408 3.408 ]
...
[24.860001 24.860001 24.860001 ... nan nan nan]
[23.455999 23.455999 23.455999 ... nan nan nan]
[19.497 19.497 19.497 ... nan nan nan]]
TEMP_MIN(10, 1023)
[[12.306 12.306 12.306 ... nan nan nan]
[ 6.827 6.827 6.827 ... 3.264 nan nan]
[ 6.827 6.827 6.827 ... 3.264 3.264 3.264 ]
...
[18.333 18.333 18.333 ... nan nan nan]
[16.757999 16.757999 16.757999 ... nan nan nan]
[ 8.983 8.983 8.983 ... nan nan nan]]
TEMP_MAX(10, 1023)
[[28.549999 28.549999 28.549999 ... nan nan nan]
[27.725 27.725 27.725 ... 3.927 nan nan]
[27.725 27.725 27.725 ... 3.927 3.927 3.927 ]
...
[28.080999 28.080999 28.080999 ... nan nan nan]
[28.186001 28.186001 28.186001 ... nan nan nan]
[26.903999 26.903999 26.903999 ... nan nan nan]]
ID(1,)
[5902393.]
PARAM(1,)
[b'S']
LON(1,)
[-176.45863342]
LAT(1,)
[-29.23719025]
POS_QC(1,)
[1.]
BAT(1,)
[1.]
JULD(1,)
[737288.87855324]
JULD_QC(1,)
[1.]
FALSEorTRUE(1,)
[1.]
PRES(1, 1008)
[[1.08000004e+00 2.03999996e+00 3.03999996e+00 ... 2.00192004e+03
2.00400000e+03 2.00607996e+03]]
PRES_QC(1, 1008)
[[1. 1. 1. ... 1. 1. 1.]]
PSAL(1, 1008)
[[35.69332123 35.69332123 35.69332123 ... 34.62292099 34.62311935
34.62332153]]
PSAL_QC(1, 1008)
[[1. 1. 1. ... 1. 1. 1.]]
PSAL_MED(1, 1008)
[[35.612 35.612 35.612 ... 34.6185015 34.6185015 34.6185015]]
PSAL_MIN(1, 1008)
[[35.41 35.41 35.41 ... 34.608002 34.608002 34.608002]]
PSAL_MAX(1, 1008)
[[35.736 35.736 35.736 ... 34.632 34.632 34.632]]
TEMP(1, 1008)
[[19.04599953 19.04500008 19.04500008 ... 2.36599994 2.36299992
2.36299992]]
TEMP_QC(1, 1008)
[[1. 1. 1. ... 1. 1. 1.]]
TEMP_MED(1, 1008)
[[21.983 21.983 21.983 ... 2.387 2.387 2.387]]
TEMP_MIN(1, 1008)
[[18.431999 18.431999 18.431999 ... 2.303 2.303 2.303 ]]
TEMP_MAX(1, 1008)
[[25.636999 25.636999 25.636999 ... 2.458 2.458 2.458 ]]
PRESs(200,)
[ -5. 20. 20. 40. 40. 60. 60. 80. 80. 100. 100. 120.
120. 140. 140. 160. 160. 180. 180. 200. 200. 220. 220. 240.
240. 260. 260. 280. 280. 300. 300. 320. 320. 340. 340. 360.
360. 380. 380. 400. 400. 420. 420. 440. 440. 460. 460. 480.
480. 500. 500. 520. 520. 540. 540. 560. 560. 580. 580. 600.
600. 620. 620. 640. 640. 660. 660. 680. 680. 700. 700. 720.
720. 740. 740. 760. 760. 780. 780. 800. 800. 820. 820. 840.
840. 860. 860. 880. 880. 900. 900. 920. 920. 940. 940. 960.
960. 980. 980. 1000. 1000. 1020. 1020. 1040. 1040. 1060. 1060. 1080.
1080. 1100. 1100. 1120. 1120. 1140. 1140. 1160. 1160. 1180. 1180. 1200.
1200. 1220. 1220. 1240. 1240. 1260. 1260. 1280. 1280. 1300. 1300. 1320.
1320. 1340. 1340. 1360. 1360. 1380. 1380. 1400. 1400. 1420. 1420. 1440.
1440. 1460. 1460. 1480. 1480. 1500. 1500. 1520. 1520. 1540. 1540. 1560.
1560. 1580. 1580. 1600. 1600. 1620. 1620. 1640. 1640. 1660. 1660. 1680.
1680. 1700. 1700. 1720. 1720. 1740. 1740. 1760. 1760. 1780. 1780. 1800.
1800. 1820. 1820. 1840. 1840. 1860. 1860. 1880. 1880. 1900. 1900. 1920.
1920. 1940. 1940. 1960. 1960. 1980. 1980. 2050.]
PSAL_MEDs(10, 200)
[[36.188999 36.188999 36.2029515 ... 34.9677505 34.9670485 34.9670485]
[35.796001 35.796001 35.7954505 ... 34.94545 34.945801 34.945801 ]
[35.796001 35.796001 35.7954505 ... 34.94545 34.945801 34.945801 ]
...
[36.3145925 36.3145925 36.314079 ... 34.964001 34.9620075 34.9620075]
[36.3855 36.3855 36.370489 ... 34.963001 34.964001 34.964001 ]
[35.993 35.993 35.9934995 ... 34.950311 34.949001 34.949001 ]]
PSAL_MINs(10, 200)
[[34.314999 34.314999 34.293098 ... 34.929588 34.929001 34.929001]
[32.966 32.966 33.021198 ... 34.932416 34.932999 34.932999]
[32.966 32.966 33.021198 ... 34.932416 34.932999 34.932999]
...
[35.266998 35.266998 35.25 ... 34.940755 34.938999 34.938999]
[34.800098 34.800098 35.735001 ... 34.93733 34.937 34.937 ]
[33.67799 33.67799 34.540737 ... 34.924932 34.928001 34.928001]]
PSAL_MAXs(10, 200)
[[36.653099 36.653099 36.653198 ... 34.984001 34.985134 34.985134]
[36.662998 36.662998 36.661999 ... 34.981998 34.981998 34.981998]
[36.662998 36.662998 36.661999 ... 34.981998 34.981998 34.981998]
...
[36.606998 36.606998 36.607018 ... 34.98 34.981998 34.981998]
[36.623009 36.623009 36.623001 ... 34.980999 34.980999 34.980999]
[36.659 36.659 36.711037 ... 34.967999 34.966999 34.966999]]
TEMP_MEDs(10, 200)
[[23.509001 23.509001 22.764999 ... 3.865 3.844 3.844 ]
[20.3086005 20.3086005 20.082999 ... 3.420315 3.408 3.408 ]
[20.3086005 20.3086005 20.082999 ... 3.420315 3.408 3.408 ]
...
[24.860001 24.860001 24.46 ... 3.919 3.89 3.89 ]
[23.455999 23.455999 23.139501 ... 3.98 3.9665 3.9665 ]
[19.497 19.497 19.177 ... 3.7035 3.678 3.678 ]]
TEMP_MINs(10, 200)
[[12.306 12.306 12.061 ... 3.469232 3.435 3.435 ]
[ 6.827 6.827 7.0105 ... 3.284 3.264 3.264 ]
[ 6.827 6.827 7.0105 ... 3.284 3.264 3.264 ]
...
[18.333 18.333 18.334999 ... 3.546 3.499 3.499 ]
[16.757999 16.757999 16.729 ... 3.56034 3.544 3.544 ]
[ 8.983 8.983 9.695 ... 3.433419 3.434 3.434 ]]
TEMP_MAXs(10, 200)
[[12.306 28.549999 12.061 ... 4.15 3.435 4.142 ]
[ 6.827 27.725 7.0105 ... 3.946 3.264 3.927 ]
[ 6.827 27.725 7.0105 ... 3.946 3.264 3.927 ]
...
[18.333 28.080999 18.334999 ... 4.064183 3.499 4.053 ]
[16.757999 28.186001 16.729 ... 4.335 3.544 4.314 ]
[ 8.983 26.903999 9.695 ... 3.891892 3.434 3.866 ]]
PSAL_MEDs(1, 200)
[[35.612 35.612 35.6461885 35.6461885 35.6774995 35.6774995
35.674999 35.674999 35.66 35.66 35.640501 35.640501
35.6064985 35.6064985 35.576 35.576 35.5555 35.5555
35.525002 35.525002 35.487 35.487 35.461536 35.461536
35.421692 35.421692 35.3605005 35.3605005 35.317001 35.317001
35.263216 35.263216 35.2435 35.2435 35.1461505 35.1461505
35.079507 35.079507 35.007 35.007 34.972386 34.972386
34.904515 34.904515 34.841 34.841 34.784414 34.784414
34.706001 34.706001 34.679986 34.679986 34.635945 34.635945
34.588619 34.588619 34.549747 34.549747 34.502731 34.502731
34.487406 34.487406 34.466534 34.466534 34.433998 34.433998
34.421313 34.421313 34.402378 34.402378 34.39606 34.39606
34.38526 34.38526 34.375 34.375 34.3653305 34.3653305
34.356304 34.356304 34.3543625 34.3543625 34.3521 34.3521
34.350195 34.350195 34.34843 34.34843 34.3466725 34.3466725
34.3461165 34.3461165 34.344837 34.344837 34.348 34.348
34.347054 34.347054 34.3480735 34.3480735 34.3474315 34.3474315
34.3550305 34.3550305 34.357611 34.357611 34.3624655 34.3624655
34.370628 34.370628 34.372883 34.372883 34.377059 34.377059
34.3822305 34.3822305 34.3906215 34.3906215 34.402714 34.402714
34.4075905 34.4075905 34.4167915 34.4167915 34.4256685 34.4256685
34.434753 34.434753 34.4476965 34.4476965 34.453896 34.453896
34.4657205 34.4657205 34.4771405 34.4771405 34.48754 34.48754
34.502121 34.502121 34.5070415 34.5070415 34.5160115 34.5160115
34.523035 34.523035 34.529335 34.529335 34.537029 34.537029
34.543737 34.543737 34.548712 34.548712 34.553499 34.553499
34.560501 34.560501 34.5650405 34.5650405 34.572206 34.572206
34.5781695 34.5781695 34.583 34.583 34.5846395 34.5846395
34.5865885 34.5865885 34.5877905 34.5877905 34.5900925 34.5900925
34.591999 34.591999 34.5953285 34.5953285 34.5993835 34.5993835
34.6009 34.6009 34.603407 34.603407 34.6055015 34.6055015
34.6075795 34.6075795 34.610514 34.610514 34.611377 34.611377
34.6129805 34.6129805 34.6145 34.6145 34.617977 34.617977
34.6185015 34.6185015]]
PSAL_MINs(1, 200)
[[35.41 35.41 35.41 35.41 35.419998 35.419998 35.508507
35.508507 35.553299 35.553299 35.584999 35.584999 35.551998 35.551998
35.488998 35.488998 35.417999 35.417999 35.261002 35.261002 35.192001
35.192001 35.176998 35.176998 35.101002 35.101002 35.042999 35.042999
35.002998 35.002998 34.978001 34.978001 34.923 34.923 34.827
34.827 34.796001 34.796001 34.721001 34.721001 34.691449 34.691449
34.635691 34.635691 34.580002 34.580002 34.543568 34.543568 34.488998
34.488998 34.478025 34.478025 34.454215 34.454215 34.431 34.431
34.416534 34.416534 34.396 34.396 34.39206 34.39206 34.382191
34.382191 34.368999 34.368999 34.365269 34.365269 34.360001 34.360001
34.356108 34.356108 34.348964 34.348964 34.341999 34.341999 34.340765
34.340765 34.338001 34.338001 34.336997 34.336997 34.333028 34.333028
34.328999 34.328999 34.330973 34.330973 34.330002 34.330002 34.330218
34.330218 34.330613 34.330613 34.331001 34.331001 34.33285 34.33285
34.334 34.334 34.337686 34.337686 34.338885 34.338885 34.34
34.34 34.343852 34.343852 34.348999 34.348999 34.351039 34.351039
34.354619 34.354619 34.358002 34.358002 34.367286 34.367286 34.380001
34.380001 34.384924 34.384924 34.393795 34.393795 34.402 34.402
34.411498 34.411498 34.424 34.424 34.43028 34.43028 34.441016
34.441016 34.451 34.451 34.463032 34.463032 34.479 34.479
34.482697 34.482697 34.489071 34.489071 34.494999 34.494999 34.503525
34.503525 34.514999 34.514999 34.517459 34.517459 34.521851 34.521851
34.526001 34.526001 34.532753 34.532753 34.542 34.542 34.545336
34.545336 34.551348 34.551348 34.556999 34.556999 34.562556 34.562556
34.57 34.57 34.572297 34.572297 34.576259 34.576259 34.580002
34.580002 34.583412 34.583412 34.588001 34.588001 34.589158 34.589158
34.591153 34.591153 34.592999 34.592999 34.595154 34.595154 34.598
34.598 34.599389 34.599389 34.601784 34.601784 34.604 34.604
34.605724 34.605724 34.608002 34.608002]]
PSAL_MAXs(1, 200)
[[35.736 35.736 35.745998 35.745998 35.744999 35.744999 35.715
35.715 35.699001 35.699001 35.678001 35.678001 35.667999 35.667999
35.653999 35.653999 35.636002 35.636002 35.627998 35.627998 35.587002
35.587002 35.577 35.577 35.592999 35.592999 35.525002 35.525002
35.474998 35.474998 35.425999 35.425999 35.382 35.382 35.333
35.333 35.220001 35.220001 35.160999 35.160999 35.121681 35.121681
35.081451 35.081451 35.067001 35.067001 34.989928 34.989928 34.883999
34.883999 34.837638 34.837638 34.753344 34.753344 34.703999 34.703999
34.655856 34.655856 34.611 34.611 34.596289 34.596289 34.569782
34.569782 34.544998 34.544998 34.512099 34.512099 34.466999 34.466999
34.463536 34.463536 34.457124 34.457124 34.451 34.451 34.436816
34.436816 34.417 34.417 34.409989 34.409989 34.397007 34.397007
34.384998 34.384998 34.39103 34.39103 34.398998 34.398998 34.392772
34.392772 34.382038 34.382038 34.372002 34.372002 34.367995 34.367995
34.381001 34.381001 34.382727 34.382727 34.385952 34.385952 34.389
34.389 34.396923 34.396923 34.408001 34.408001 34.411361 34.411361
34.41776 34.41776 34.424 34.424 34.428107 34.428107 34.433998
34.433998 34.438672 34.438672 34.447491 34.447491 34.456001 34.456001
34.465877 34.465877 34.48 34.48 34.484211 34.484211 34.492308
34.492308 34.5 34.5 34.510019 34.510019 34.523998 34.523998
34.52851 34.52851 34.536944 34.536944 34.544998 34.544998 34.552077
34.552077 34.562 34.562 34.564573 34.564573 34.569383 34.569383
34.574001 34.574001 34.578186 34.578186 34.584 34.584 34.585986
34.585986 34.589564 34.589564 34.592999 34.592999 34.5955 34.5955
34.598999 34.598999 34.600743 34.600743 34.603942 34.603942 34.606998
34.606998 34.609501 34.609501 34.612999 34.612999 34.614292 34.614292
34.616688 34.616688 34.618999 34.618999 34.620662 34.620662 34.623001
34.623001 34.624301 34.624301 34.626687 34.626687 34.629002 34.629002
34.63023 34.63023 34.632 34.632 ]]
TEMP_MEDs(1, 200)
[[21.983 21.983 21.5159995 21.5159995 20.7440005 20.7440005
20.124001 20.124001 19.3295 19.3295 18.62 18.62
18.123 18.123 17.679001 17.679001 17.4735005 17.4735005
16.844 16.844 16.389999 16.389999 16.007 16.007
15.557 15.557 15.1325 15.1325 14.794 14.794
14.284 14.284 13.951 13.951 13.484 13.484
12.91 12.91 12.3475 12.3475 12.173699 12.173699
11.598598 11.598598 11.035 11.035 10.579048 10.579048
9.95 9.95 9.705498 9.705498 9.275 9.275
8.951 8.951 8.608 8.608 8.171 8.171
7.994871 7.994871 7.755 7.755 7.461 7.461
7.268191 7.268191 7.059 7.059 6.963477 6.963477
6.799637 6.799637 6.63 6.63 6.5502645 6.5502645
6.3785 6.3785 6.316294 6.316294 6.204189 6.204189
6.1025 6.1025 5.986183 5.986183 5.813 5.813
5.7490115 5.7490115 5.6148935 5.6148935 5.47 5.47
5.3792375 5.3792375 5.217 5.217 4.8853685 4.8853685
4.7673145 4.7673145 4.6525 4.6525 4.546351 4.546351
4.396 4.396 4.33777 4.33777 4.230815 4.230815
4.126 4.126 4.0246145 4.0246145 3.8785 3.8785
3.8298555 3.8298555 3.738073 3.738073 3.6495 3.6495
3.574027 3.574027 3.458 3.458 3.411365 3.411365
3.3250035 3.3250035 3.2435 3.2435 3.187438 3.187438
3.109 3.109 3.081 3.081 3.0252625 3.0252625
2.979 2.979 2.9427625 2.9427625 2.902 2.902
2.8661615 2.8661615 2.843538 2.843538 2.8215 2.8215
2.783216 2.783216 2.765 2.765 2.721182 2.721182
2.694024 2.694024 2.6725 2.6725 2.647399 2.647399
2.6152885 2.6152885 2.6070325 2.6070325 2.590732 2.590732
2.5775 2.5775 2.5630005 2.5630005 2.545584 2.545584
2.5354155 2.5354155 2.512865 2.512865 2.4945 2.4945
2.4776765 2.4776765 2.462 2.462 2.4462685 2.4462685
2.430285 2.430285 2.4155 2.4155 2.376439 2.376439
2.387 2.387 ]]
TEMP_MINs(1, 200)
[[18.431999 18.431999 18.431 18.431 18.405001 18.405001 17.931999
17.931999 17.459 17.459 16.898001 16.898001 16.577999 16.577999
15.978 15.978 15.463 15.463 14.477 14.477 13.937
13.937 13.662 13.662 13.052 13.052 12.584 12.584
12.21 12.21 11.975 11.975 11.589 11.589 11.
11. 10.605 10.605 10.109 10.109 9.849606 9.849606
9.352636 9.352636 8.883 8.883 8.523503 8.523503 8.026
8.026 7.902756 7.902756 7.674525 7.674525 7.428 7.428
7.229613 7.229613 6.948 6.948 6.872269 6.872269 6.733313
6.733313 6.573 6.573 6.482227 6.482227 6.354 6.354
6.274196 6.274196 6.127768 6.127768 5.985 5.985 5.880442
5.880442 5.731 5.731 5.675685 5.675685 5.567992 5.567992
5.46 5.46 5.340454 5.340454 5.171 5.171 5.112563
5.112563 5.004347 5.004347 4.806 4.806 4.715908 4.715908
4.589 4.589 4.508319 4.508319 4.357512 4.357512 4.215
4.215 4.144945 4.144945 4.047 4.047 4.00143 4.00143
3.91463 3.91463 3.83 3.83 3.740852 3.740852 3.613
3.613 3.570728 3.570728 3.490968 3.490968 3.414 3.414
3.343217 3.343217 3.242 3.242 3.216526 3.216526 3.167538
3.167538 3.121 3.121 3.062551 3.062551 2.981 2.981
2.956506 2.956506 2.910723 2.910723 2.867 2.867 2.823285
2.823285 2.762 2.762 2.74892 2.74892 2.724471 2.724471
2.701 2.701 2.677982 2.677982 2.646 2.646 2.634084
2.634084 2.612612 2.612612 2.592 2.592 2.572826 2.572826
2.546 2.546 2.53619 2.53619 2.51819 2.51819 2.501
2.501 2.485982 2.485982 2.465 2.465 2.456377 2.456377
2.440409 2.440409 2.425 2.425 2.410867 2.410867 2.391
2.391 2.379515 2.379515 2.358441 2.358441 2.338 2.338
2.323666 2.323666 2.303 2.303 ]]
TEMP_MAXs(1, 200)
[[18.431999 25.636999 18.431 25.01 18.405001 24.504999 17.931999
23.291 17.459 21.289 16.898001 20.158001 16.577999 19.415001
15.978 18.871 15.463 18.389 14.477 17.976 13.937
17.591 13.662 17.225 13.052 16.959 12.584 16.486
12.21 16.153 11.975 15.706 11.589 15.185 11.
14.71 10.605 14.071 10.109 13.495 9.849606 13.1825
9.352636 12.735817 8.883 12.47 8.523503 11.903543 8.026
11.125 7.902756 10.785378 7.674525 10.167882 7.428 9.825
7.229613 9.386641 6.948 8.802 6.872269 8.676289 6.733313
8.449783 6.573 8.238 6.482227 7.965529 6.354 7.592
6.274196 7.508241 6.127768 7.35313 5.985 7.205 5.880442
7.044808 5.731 6.821 5.675685 6.718915 5.567992 6.534093
5.46 6.444 5.340454 6.313121 5.171 6.189 5.112563
6.09537 5.004347 5.933939 4.806 5.783 4.715908 5.615206
4.589 5.482 4.508319 5.166117 4.357512 5.037891 4.215
4.918 4.144945 4.779952 4.047 4.613 4.00143 4.556567
3.91463 4.457561 3.83 4.364 3.740852 4.21841 3.613
4.019 3.570728 3.965067 3.490968 3.867889 3.414 3.778
3.343217 3.685611 3.242 3.564 3.216526 3.522364 3.167538
3.451191 3.121 3.385 3.062551 3.295189 2.981 3.176
2.956506 3.155665 2.910723 3.120606 2.867 3.088 2.823285
3.047502 2.762 2.993 2.74892 2.973998 2.724471 2.940066
2.701 2.908 2.677982 2.872552 2.646 2.824 2.634084
2.807984 2.612612 2.779126 2.592 2.752 2.572826 2.7255
2.546 2.695 2.53619 2.676677 2.51819 2.653707 2.501
2.632 2.485982 2.605998 2.465 2.592 2.456377 2.560349
2.440409 2.541986 2.425 2.525 2.410867 2.507335 2.391
2.519 2.379515 2.476769 2.358441 2.466306 2.338 2.456
2.323666 2.429212 2.303 2.458 ]]
/tmp/ipykernel_204815/2633307002.py:4: DeprecationWarning: `scipy.io.netcdf.NetCDFFile` is deprecated along with the `scipy.io.netcdf` namespace. `scipy.io.netcdf.NetCDFFile` will be removed in SciPy 1.14.0, and the `scipy.io.netcdf` namespace will be removed in SciPy 2.0.0.
file = netcdf.NetCDFFile("./Dataset/"+filename, 'r')
/tmp/ipykernel_133376/2058552270.py:4: DeprecationWarning: `scipy.io.netcdf.NetCDFFile` is deprecated along with the `scipy.io.netcdf` namespace. `scipy.io.netcdf.NetCDFFile` will be removed in SciPy 1.14.0, and the `scipy.io.netcdf` namespace will be removed in SciPy 2.0.0.
file = netcdf.NetCDFFile("./dataset/"+filename, 'r')
%% Cell type:code id: tags:
``` python
import xarray as xr
dataframes = []
for filename in os.listdir("./dataset"):
#file2read = netcdf.NetCDFFile(, 'r')
ds = xr.open_dataset("./dataset/"+filename)
df = ds.to_dataframe()
dataframes.append(df)
break
pd.set_option('display.max_rows', 100)
df
```
%% Output
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[51], line 5
2 dataframes = []
3 for filename in os.listdir("./Dataset"):
4 #file2read = netcdf.NetCDFFile(, 'r')
----> 5 ds = xr.open_dataset("./Dataset/"+filename, combine='by_coords')
6 df = ds.to_dataframe()
7 dataframes.append(df)
File ~/miniforge3/envs/ml_op_dec/lib/python3.11/site-packages/xarray/backends/api.py:573, in open_dataset(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, inline_array, chunked_array_type, from_array_kwargs, backend_kwargs, **kwargs)
561 decoders = _resolve_decoders_kwargs(
562 decode_cf,
563 open_backend_dataset_parameters=backend.open_dataset_parameters,
(...)
569 decode_coords=decode_coords,
570 )
572 overwrite_encoded_chunks = kwargs.pop("overwrite_encoded_chunks", None)
--> 573 backend_ds = backend.open_dataset(
574 filename_or_obj,
575 drop_variables=drop_variables,
576 **decoders,
577 **kwargs,
578 )
579 ds = _dataset_from_backend_dataset(
580 backend_ds,
581 filename_or_obj,
(...)
591 **kwargs,
592 )
593 return ds
TypeError: ScipyBackendEntrypoint.open_dataset() got an unexpected keyword argument 'combine'
ID PARAM LON LAT POS_QC \
N_PROF N_LEVELS N_LEVELS_2
0 0 0 5902393.0 b'S' -176.458633 -29.23719 1.0
1 5902393.0 b'S' -176.458633 -29.23719 1.0
2 5902393.0 b'S' -176.458633 -29.23719 1.0
3 5902393.0 b'S' -176.458633 -29.23719 1.0
4 5902393.0 b'S' -176.458633 -29.23719 1.0
... ... ... ... ... ...
1007 195 5902393.0 b'S' -176.458633 -29.23719 1.0
196 5902393.0 b'S' -176.458633 -29.23719 1.0
197 5902393.0 b'S' -176.458633 -29.23719 1.0
198 5902393.0 b'S' -176.458633 -29.23719 1.0
199 5902393.0 b'S' -176.458633 -29.23719 1.0
BAT JULD JULD_QC FALSEorTRUE \
N_PROF N_LEVELS N_LEVELS_2
0 0 0 1.0 737288.878553 1.0 1.0
1 1.0 737288.878553 1.0 1.0
2 1.0 737288.878553 1.0 1.0
3 1.0 737288.878553 1.0 1.0
4 1.0 737288.878553 1.0 1.0
... ... ... ... ...
1007 195 1.0 737288.878553 1.0 1.0
196 1.0 737288.878553 1.0 1.0
197 1.0 737288.878553 1.0 1.0
198 1.0 737288.878553 1.0 1.0
199 1.0 737288.878553 1.0 1.0
PRES ... TEMP_MED TEMP_MIN TEMP_MAX \
N_PROF N_LEVELS N_LEVELS_2 ...
0 0 0 1.080000 ... 21.983 18.431999 25.636999
1 1.080000 ... 21.983 18.431999 25.636999
2 1.080000 ... 21.983 18.431999 25.636999
3 1.080000 ... 21.983 18.431999 25.636999
4 1.080000 ... 21.983 18.431999 25.636999
... ... ... ... ... ...
1007 195 2006.079956 ... 2.387 2.303000 2.458000
196 2006.079956 ... 2.387 2.303000 2.458000
197 2006.079956 ... 2.387 2.303000 2.458000
198 2006.079956 ... 2.387 2.303000 2.458000
199 2006.079956 ... 2.387 2.303000 2.458000
PRESs PSAL_MEDs PSAL_MINs PSAL_MAXs \
N_PROF N_LEVELS N_LEVELS_2
0 0 0 -5.0 35.612000 35.410000 35.736000
1 20.0 35.612000 35.410000 35.736000
2 20.0 35.646189 35.410000 35.745998
3 40.0 35.646189 35.410000 35.745998
4 40.0 35.677499 35.419998 35.744999
... ... ... ... ...
1007 195 1960.0 34.614500 34.604000 34.629002
196 1960.0 34.617977 34.605724 34.630230
197 1980.0 34.617977 34.605724 34.630230
198 1980.0 34.618502 34.608002 34.632000
199 2050.0 34.618502 34.608002 34.632000
TEMP_MEDs TEMP_MINs TEMP_MAXs
N_PROF N_LEVELS N_LEVELS_2
0 0 0 21.983000 18.431999 18.431999
1 21.983000 18.431999 25.636999
2 21.515999 18.431000 18.431000
3 21.515999 18.431000 25.010000
4 20.744000 18.405001 18.405001
... ... ... ...
1007 195 2.415500 2.338000 2.456000
196 2.376439 2.323666 2.323666
197 2.376439 2.323666 2.429212
198 2.387000 2.303000 2.303000
199 2.387000 2.303000 2.458000
[201600 rows x 28 columns]
%% Cell type:code id: tags:
``` python
df['TEMP_MED'].unique().shape
```
%% Output
(781,)
%% Cell type:code id: tags:
``` python
import xarray as xr
dataframes = []
for filename in os.listdir("./dataset"):
#file2read = netcdf.NetCDFFile(, 'r')
ds = xr.open_dataset("./dataset/"+filename, decode_coords=False)
df = ds.to_dataframe()
dataframes.append(df)
break
df
#dfs = [pd.DataFrame(df[col]) for col in ['TEMP', 'TEMP_QC']]
#merged_df = pd.concat(dfs, axis=1)
#merged_df
#frame_in = df['TEMP'].to_frame()
#df2 = pd.DataFrame(frame_in['TEMP'])
#df2 = df2.reset_index()
#df2
```
%% Output
ID PARAM LON LAT POS_QC \
N_PROF N_LEVELS N_LEVELS_2
0 0 0 4902348.0 b'S' -63.302200 39.284649 1.0
1 4902348.0 b'S' -63.302200 39.284649 1.0
2 4902348.0 b'S' -63.302200 39.284649 1.0
3 4902348.0 b'S' -63.302200 39.284649 1.0
4 4902348.0 b'S' -63.302200 39.284649 1.0
... ... ... ... ... ...
9 1022 195 4902348.0 b'T' -56.677368 40.983768 1.0
196 4902348.0 b'T' -56.677368 40.983768 1.0
197 4902348.0 b'T' -56.677368 40.983768 1.0
198 4902348.0 b'T' -56.677368 40.983768 1.0
199 4902348.0 b'T' -56.677368 40.983768 1.0
BAT JULD JULD_QC FALSEorTRUE PRES \
N_PROF N_LEVELS N_LEVELS_2
0 0 0 1.0 737242.992222 1.0 1.0 0.48
1 1.0 737242.992222 1.0 1.0 0.48
2 1.0 737242.992222 1.0 1.0 0.48
3 1.0 737242.992222 1.0 1.0 0.48
4 1.0 737242.992222 1.0 1.0 0.48
... ... ... ... ... ...
9 1022 195 1.0 737331.688414 1.0 1.0 NaN
196 1.0 737331.688414 1.0 1.0 NaN
197 1.0 737331.688414 1.0 1.0 NaN
198 1.0 737331.688414 1.0 1.0 NaN
199 1.0 737331.688414 1.0 1.0 NaN
... TEMP_MED TEMP_MIN TEMP_MAX PRESs \
N_PROF N_LEVELS N_LEVELS_2 ...
0 0 0 ... 23.509001 12.306 28.549999 -5.0
1 ... 23.509001 12.306 28.549999 20.0
2 ... 23.509001 12.306 28.549999 20.0
3 ... 23.509001 12.306 28.549999 40.0
4 ... 23.509001 12.306 28.549999 40.0
... ... ... ... ... ...
9 1022 195 ... NaN NaN NaN 1960.0
196 ... NaN NaN NaN 1960.0
197 ... NaN NaN NaN 1980.0
198 ... NaN NaN NaN 1980.0
199 ... NaN NaN NaN 2050.0
PSAL_MEDs PSAL_MINs PSAL_MAXs TEMP_MEDs \
N_PROF N_LEVELS N_LEVELS_2
0 0 0 36.188999 34.314999 36.653099 23.509001
1 36.188999 34.314999 36.653099 23.509001
2 36.202951 34.293098 36.653198 22.764999
3 36.202951 34.293098 36.653198 22.764999
4 36.238350 34.699799 36.750008 21.418000
... ... ... ... ...
9 1022 195 34.951000 34.911999 34.969040 3.722000
196 34.950311 34.924932 34.967999 3.703500
197 34.950311 34.924932 34.967999 3.703500
198 34.949001 34.928001 34.966999 3.678000
199 34.949001 34.928001 34.966999 3.678000
TEMP_MINs TEMP_MAXs
N_PROF N_LEVELS N_LEVELS_2
0 0 0 12.306000 12.306000
1 12.306000 28.549999
2 12.061000 12.061000
3 12.061000 28.509001
4 10.897000 10.897000
... ... ...
9 1022 195 3.433000 3.912000
196 3.433419 3.433419
197 3.433419 3.891892
198 3.434000 3.434000
199 3.434000 3.866000
[2046000 rows x 28 columns]
%% Cell type:code id: tags:
``` python
import cf_xarray as cfxr
import pandas as pd
# Open the netCDF file using xarray
for f in os.listdir("./dataset"):
ds = xr.open_dataset("./dataset/"+f)
break
# Apply cf-xarray to decode CF conventions
ds_cfxr = cfxr.open_dataset(ds)
# Convert to pandas DataFrame
df = ds_cfxr.to_dataframe()
# Optionally, close the netCDF dataset
ds.close()
# Now you have the data in a pandas DataFrame
print(df)
```
%% Output
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[39], line 10
7 break
9 # Apply cf-xarray to decode CF conventions
---> 10 ds_cfxr = cfxr.open_dataset(ds)
12 # Convert to pandas DataFrame
13 df = ds_cfxr.to_dataframe()
AttributeError: module 'cf_xarray' has no attribute 'open_dataset'
%% Cell type:code id: tags:
``` python
import xarray as xr
ds = xr.open_dataset('./dataset/LD_1900973.nc')
ds.variables
```
%% Output
Frozen({'ID': <xarray.Variable (N_PROF: 1)> Size: 8B
[1 values with dtype=float64], 'PARAM': <xarray.Variable (N_PROF: 1)> Size: 1B
[1 values with dtype=|S1], 'LON': <xarray.Variable (N_PROF: 1)> Size: 8B
[1 values with dtype=float64], 'LAT': <xarray.Variable (N_PROF: 1)> Size: 8B
[1 values with dtype=float64], 'POS_QC': <xarray.Variable (N_PROF: 1)> Size: 8B
[1 values with dtype=float64], 'BAT': <xarray.Variable (N_PROF: 1)> Size: 8B
[1 values with dtype=float64], 'JULD': <xarray.Variable (N_PROF: 1)> Size: 8B
[1 values with dtype=float64], 'JULD_QC': <xarray.Variable (N_PROF: 1)> Size: 8B
[1 values with dtype=float64], 'FALSEorTRUE': <xarray.Variable (N_PROF: 1)> Size: 8B
[1 values with dtype=float64], 'PRES': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'PRES_QC': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'PSAL': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'PSAL_QC': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'PSAL_MED': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'PSAL_MIN': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'PSAL_MAX': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'TEMP': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'TEMP_QC': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'TEMP_MED': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'TEMP_MIN': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'TEMP_MAX': <xarray.Variable (N_PROF: 1, N_LEVELS: 72)> Size: 576B
[72 values with dtype=float64], 'PRESs': <xarray.Variable (N_LEVELS_2: 200)> Size: 2kB
[200 values with dtype=float64], 'PSAL_MEDs': <xarray.Variable (N_PROF: 1, N_LEVELS_2: 200)> Size: 2kB
[200 values with dtype=float64], 'PSAL_MINs': <xarray.Variable (N_PROF: 1, N_LEVELS_2: 200)> Size: 2kB
[200 values with dtype=float64], 'PSAL_MAXs': <xarray.Variable (N_PROF: 1, N_LEVELS_2: 200)> Size: 2kB
[200 values with dtype=float64], 'TEMP_MEDs': <xarray.Variable (N_PROF: 1, N_LEVELS_2: 200)> Size: 2kB
[200 values with dtype=float64], 'TEMP_MINs': <xarray.Variable (N_PROF: 1, N_LEVELS_2: 200)> Size: 2kB
[200 values with dtype=float64], 'TEMP_MAXs': <xarray.Variable (N_PROF: 1, N_LEVELS_2: 200)> Size: 2kB
[200 values with dtype=float64]})
%% Cell type:code id: tags:
``` python
```
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment