[ncl-talk] Read Matlab file and shift data longitudinally

Giorgio Graffino g.graffino at tim.it
Fri Dec 15 05:31:31 MST 2023


Dear NCL experts,
 
Hope you're all well. As per the subject, I want to read a .mat file 
containing daily SST data from 1940 to 2005 and run some analysis I've 
already written in NCL. If I try to directly read the file with NCL I 
get Segmentation fault, so that's not the right way to go. I converted 
the file into NetCDF using Matlab 
(https://uk.mathworks.com/help/matlab/import_export/exporting-to-network-common-data-form-netcdf-files.html?s_tid=answers_rc2-3_p6_MLT#bsxb70y-1), 
but there is a problem with the data. 
 
At some point in the time series (around 1962), the data get shifted in 
the longitude sense by about 40 degrees. I checked this in NCL and in 
Ferret, as shown in the attached screenshot: the left-hand side is SST 
on a random day before 1962, while the right-hand side is after 1962. 
It's like there is an offset in the data longitudes. The plots are drawn 
using only four lines in Ferret, so the error can't be due to the the 
software. There must be something wrong going on when the file is 
created. It would be great to know what happens to the data in the first 
place, but maybe it's a discussion that doesn't belong here.
 
This is the printVarSummary of the full data. The longitudes array does 
not change over time, but the data are shifted.
 
Variable: temp
Type: float
Total Size: 710269560 bytes
           177567390 values
Number of Dimensions: 3
Dimensions and sizes:   [time | 24090] x [lats | 120] x [lons | 180]
Coordinates: 
           time: [350616..929160]
           lats: [ -90..88.5]
           lons: [   0.. 358]
Number Of Attributes: 1
 _FillValue :  -9e+33
 
I'd like to know how I can correct the second part of the time series to 
make it like the first part. I tried with LonFlip and LonPivot but I 
couldn't make it work. I'm thinking about a way to shift the data back 
by that longitude offset, but I can't wrap my head around it.
 
Please let me know.
 
Cheers,
Giorgio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20231215/03f30805/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screenshot_20231215_122717.png
Type: image/png
Size: 530593 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20231215/03f30805/attachment-0001.png>


More information about the ncl-talk mailing list