4

I have 20 netCDF files containing oceanographic CTD data. Each file contains the same dimension and variable names, however they differ in the size of the vertical coordinate (ie. CTD profiles inshore have a smaller depth range than profiles offshore). I need to concatenate these separate files into one netCDF file with a record variable "station".

I have tried:

ncecat -u station *.nc outfile.nc

This concatenates the files in the correct way, but it takes the dimension size of the first netCDF file (which is the smallest) and so I lose the data below the depth of the shallowest CTD profile for the rest of the netCDF files.

I'm assuming I need to add FillValues (or similar) in place of the data that is shallower than the maximum depth of the deepest CTD profile.

Is there a way to do this using ncecat?

Jimbo
  • 67
  • 6
  • Can I ask, I presume that it is not only the number of vertical levels that is changing but also the their value? Or are the shallower reporting levels identical across all CTD profiles? If the vertical levels at which data are reported on is fairly arbitrary (but monitonically increasing) then a solution based on vertical interpolation may be required. – ClimateUnboxed Jun 01 '19 at 18:17
  • @AdrianTompkins the actual values of the depth are the same (well to the third decimal place) across the stations. The only issue is that they are a bit out of sync between stations due to the removal of the surface soak of the CTD (this depth can vary slightly), but that is an easy fix. My problem was more to do with storage rather than data analysis, and so the answer provided by Charlie Zender seems to do the trick... for my purpose at least. Thanks for your comment!!! – Jimbo Jun 03 '19 at 08:24

1 Answers1

2

The closest you can get with ncecat alone is to use group aggregation to store each station profile as its own group in a netCDF4 file. Then you do not need to search for and fill-in any missing data:

ncecat --gag *.nc outfile.nc
Charlie Zender
  • 5,929
  • 14
  • 19
  • Oh cool this works well, thank you! Now just need to practice indexing and navigating these sorts of files in python :D. – Jimbo Jun 03 '19 at 05:54