[Thread Prev][Thread Next][Index]

Re: re-arranging time axis and layout of netcdf file in ferret (fwd)



Hi Jozef,
You can reset the time origin in Ferret by defining a new time
axis with the correct origin, and use a regridding operation to
put your data onto that.  (Or, if your NetCDF file is incorrect,
and all you want to do is edit the NetCDF file, you can  use
ncdump and ncgen to edit the file, similar to what is done in this FAQ:
http://ferret.pmel.noaa.gov/Ferret/FAQ/error_messages/max_coordinates.html )

As to the latitude coordinates, Ferret will automatically see  that the
latitude axis is reversed, from the units of degrees_south, and should
read the data correctly.  If you SAVE the data to a new NetCDF file,
the output latitude axis will have units of degrees_north.

For longitude, check whether the file is modulo when you open your file.
Do a "show grid sst" command.  Does the longitude axis have an "m" after
it, just after the number of points?  I think this will be the case.  If so it is
already treated as a modulo axis and when you SAVE the data to a new
file you can specify the range that you want.  If the axis has not been
marked as modulo (which can happen if the axis is slightly longer than
360 degrees) then you can set it to be modulo with the command
SET AXIS/MODULO axisname

So, to summarize, you can use Ferret to write a new NetCDF file with
commands along  these lines:

  USE HadISST.nc

  ! Get the range of time coordinates and define the new time axis.
  LIST/L=1 t[gt=sst]
  LET nt = `t[gt=sst],return=lend`
  LIST/L=`nt` t[gt=sst]

  ! Use the dates you just listed from the file to define your new axis,
  ! something like:
  DEFINE AXIS/T="1-jan-1950":"15-dec:1990":1/units=days/t0="1-jan-1870" t_1870

  ! See if the lon axis is modulo, if not set it to be
  SHOW GRID sst
  SET AXIS/MODULO lon

  SAVE/FILE=newHadISST.nc  sst[X=0:360,GT=t_1870]

To regrid to another resolution, you would define the new X and Y
axes using /UNITS=degrees.  Define the X axis to be /MODULO.
Then on the output step you can regrid by specifying
SST[GX=newx,GY=newy,GT=t1870].

Ansley Manke


Jozef SYKTUS wrote:

> Dear Ferreters
>
> I have SST data file in netcdf and I need to rearrange it's time axis
> origin, rearrange the layout of the latitudes and longitudes and re-grid
> the data to T63 AGCM resolution.
>
> I would like to redefine time
> axis from time:units = "days since 1800-1-1 00:00:00"
> to time:units = "days since 1870-01-01 00:00"
>
> How can I do it?
>
> Also I would like to flip the data to go from south pole to north pole
> and in longitude to go from 0 (Greenwich) to 360 deg
> right now the data is arranged -179.75 to 179.25
>
> Enclosed are the headers from ncdump
>
> enso=>ncdump -c HadISST.nc |pg
> netcdf HadISST {
> dimensions:
>         lat = 180 ;
>         lon = 360 ;
>         time = UNLIMITED ; // (1602 currently)
> variables:
>         float lat(lat) ;
>                 lat:title = "Latitude" ;
>                 lat:units = "degrees_south" ;
>                 lat:actual_range = "90N,90S" ;
>                 lat:delta_lat = "1" ;
>                 lat:scale_factor = 1.f ;
>                 lat:add_offset = 0.f ;
>         float lon(lon) ;
>                 lon:title = "Longitude" ;
>                 lon:units = "degrees_east" ;
>                 lon:actual_range = "180W,180E" ;
>                 lon:delta_lat = "1" ;
>                 lon:scale_factor = 1.f ;
>                 lon:add_offset = 0.f ;
>         int time(time) ;
>                 time:title = "Time" ;
>                 time:units = "days since 1800-1-1 00:00:00" ;
>                 time:scale_factor = 1.f ;
>                 time:add_offset = 0.f ;
>         short sst(time, lat, lon) ;
>                 sst:title = "SST" ;
>                 sst:units = "C" ;
>                 sst:long_name = "Monthly Sea Surface Temperature" ;
>                 sst:var_desc = "degrees C" ;
>                 sst:missing_value = -32768s ;
>                 sst:scale_factor = 0.01f ;
>                 sst:add_offset = 0.f ;
> data:
>
>  lat = 89.5, 88.5, 87.5, 86.5, 85.5, 84.5, 83.5, 82.5, 81.5, 80.5, 79.5,
>     78.5, 77.5, 76.5, 75.5, 74.5, 73.5, 72.5, 71.5, 70.5, 69.5, 68.5, 67.5,
>     66.5, 65.5, 64.5, 63.5, 62.5, 61.5, 60.5, 59.5, 58.5, 57.5, 56.5, 55.5,
>     54.5, 53.5, 52.5, 51.5, 50.5, 49.5, 48.5, 47.5, 46.5, 45.5, 44.5, 43.5,
>     42.5, 41.5, 40.5, 39.5, 38.5, 37.5, 36.5, 35.5, 34.5, 33.5, 32.5, 31.5,
>     30.5, 29.5, 28.5, 27.5, 26.5, 25.5, 24.5, 23.5, 22.5, 21.5, 20.5, 19.5,
>     18.5, 17.5, 16.5, 15.5, 14.5, 13.5, 12.5, 11.5, 10.5, 9.5, 8.5, 7.5, 6.5,
>     5.5, 4.5, 3.5, 2.5, 1.5, 0.5, -0.5, -1.5, -2.5, -3.5, -4.5, -5.5, -6.5,
>     -7.5, -8.5, -9.5, -10.5, -11.5, -12.5, -13.5, -14.5, -15.5, -16.5, -17.5,
>     -18.5, -19.5, -20.5, -21.5, -22.5, -23.5, -24.5, -25.5, -26.5, -27.5,
>     -28.5, -29.5, -30.5, -31.5, -32.5, -33.5, -34.5, -35.5, -36.5, -37.5,
>     -38.5, -39.5, -40.5, -41.5, -42.5, -43.5, -44.5, -45.5, -46.5, -47.5,
>     -48.5, -49.5, -50.5, -51.5, -52.5, -53.5, -54.5, -55.5, -56.5, -57.5,
>     -58.5, -59.5, -60.5, -61.5, -62.5, -63.5, -64.5, -65.5, -66.5, -67.5,
>     -68.5, -69.5, -70.5, -71.5, -72.5, -73.5, -74.5, -75.5, -76.5, -77.5,
>     -78.5, -79.5, -80.5, -81.5, -82.5, -83.5, -84.5, -85.5, -86.5, -87.5,
>     -88.5, -89.5 ;
>
>  lon = -179.75, -178.75, -177.75, -176.75, -175.75, -174.75, -173.75,
>     -172.75, -171.75, -170.75, -169.75, -168.75, -167.75, -166.75, -165.75,
>     -164.75, -163.75, -162.75, -161.75, -160.75, -159.75, -158.75, -157.75,
>     -156.75, -155.75, -154.75, -153.75, -152.75, -151.75, -150.75, -149.75,
>     -148.75, -147.75, -146.75, -145.75, -144.75, -143.75, -142.75, -141.75,
>     -140.75, -139.75, -138.75, -137.75, -136.75, -135.75, -134.75, -133.75,
>     -132.75, -131.75, -130.75, -129.75, -128.75, -127.75, -126.75, -125.75,
>     -124.75, -123.75, -122.75, -121.75, -120.75, -119.75, -118.75, -117.75,
>     -116.75, -115.75, -114.75, -113.75, -112.75, -111.75, -110.75, -109.75,
>     -108.75, -107.75, -106.75, -105.75, -104.75, -103.75, -102.75, -101.75,
>     -100.75, -99.75, -98.75, -97.75, -96.75, -95.75, -94.75, -93.75, -92.75,
>     -91.75, -90.75, -89.75, -88.75, -87.75, -86.75, -85.75, -84.75, -83.75,
>     -82.75, -81.75, -80.75, -79.75, -78.75, -77.75, -76.75, -75.75, -74.75,
>     -73.75, -72.75, -71.75, -70.75, -69.75, -68.75, -67.75, -66.75, -65.75,
>     -64.75, -63.75, -62.75, -61.75, -60.75, -59.75, -58.75, -57.75, -56.75,
>     -55.75, -54.75, -53.75, -52.75, -51.75, -50.75, -49.75, -48.75, -47.75,
>     -46.75, -45.75, -44.75, -43.75, -42.75, -41.75, -40.75, -39.75, -38.75,
>     -37.75, -36.75, -35.75, -34.75, -33.75, -32.75, -31.75, -30.75, -29.75,
>     -28.75, -27.75, -26.75, -25.75, -24.75, -23.75, -22.75, -21.75, -20.75,
>     -19.75, -18.75, -17.75, -16.75, -15.75, -14.75, -13.75, -12.75, -11.75,
>     -10.75, -9.75, -8.75, -7.75, -6.75, -5.75, -4.75, -3.75, -2.75, -1.75,
>     -0.75, 0.25, 1.25, 2.25, 3.25, 4.25, 5.25, 6.25, 7.25, 8.25, 9.25, 10.25,
>     11.25, 12.25, 13.25, 14.25, 15.25, 16.25, 17.25, 18.25, 19.25, 20.25,
>     21.25, 22.25, 23.25, 24.25, 25.25, 26.25, 27.25, 28.25, 29.25, 30.25,
>     31.25, 32.25, 33.25, 34.25, 35.25, 36.25, 37.25, 38.25, 39.25, 40.25,
>     41.25, 42.25, 43.25, 44.25, 45.25, 46.25, 47.25, 48.25, 49.25, 50.25,
>     51.25, 52.25, 53.25, 54.25, 55.25, 56.25, 57.25, 58.25, 59.25, 60.25,
>     61.25, 62.25, 63.25, 64.25, 65.25, 66.25, 67.25, 68.25, 69.25, 70.25,
>     71.25, 72.25, 73.25, 74.25, 75.25, 76.25, 77.25, 78.25, 79.25, 80.25,
>     81.25, 82.25, 83.25, 84.25, 85.25, 86.25, 87.25, 88.25, 89.25, 90.25,
>     91.25, 92.25, 93.25, 94.25, 95.25, 96.25, 97.25, 98.25, 99.25, 100.25,
>     101.25, 102.25, 103.25, 104.25, 105.25, 106.25, 107.25, 108.25, 109.25,
>     110.25, 111.25, 112.25, 113.25, 114.25, 115.25, 116.25, 117.25, 118.25,
>     119.25, 120.25, 121.25, 122.25, 123.25, 124.25, 125.25, 126.25, 127.25,
>     128.25, 129.25, 130.25, 131.25, 132.25, 133.25, 134.25, 135.25, 136.25,
>     137.25, 138.25, 139.25, 140.25, 141.25, 142.25, 143.25, 144.25, 145.25,
>     146.25, 147.25, 148.25, 149.25, 150.25, 151.25, 152.25, 153.25, 154.25,
>     155.25, 156.25, 157.25, 158.25, 159.25, 160.25, 161.25, 162.25, 163.25,
>     164.25, 165.25, 166.25, 167.25, 168.25, 169.25, 170.25, 171.25, 172.25,
>     173.25, 174.25, 175.25, 176.25, 177.25, 178.25, 179.25 ;
>
>   time = 25581, 25612, 25640, 25671, 25701, 25732, 25762, 25793, 25824,
> 25854 .....................
>
> I need to get to:
>
> netcdf hadsst_1870O_new {
> dimensions:
>         latitude = 96 ;
>         longitude = 192 ;
>         time = UNLIMITED ; // (1602 currently)
> variables:
>         double latitude(latitude) ;
>                 latitude:units = "degrees_north" ;
>         double longitude(longitude) ;
>                 longitude:units = "degrees_east" ;
>         double time(time) ;
>                 time:units = "days since 1870-01-01 00:00" ;
>         float hadsst(time, latitude, longitude) ;
>                 hadsst:long_name = "Sea surface temperature" ;
>                 hadsst:units = "K" ;
>                 hadsst:missing_value = -9.99999979021477e+33 ;
>
> // global attributes:
>                 :Conventions = "GDT 1.3" ;
>                 :title = "Hadley Centre GISST monthly mean" ;
> data:
>
>  latitude = -88.5721685140073, -86.7225309546681, -84.8619702920424,
>     -82.9989416428375, -81.1349768376774, -79.2705590348597,
>     -77.4058880820788, -75.541061452879, -73.6761323132091,
>     -71.8111321142745, -69.9460806469834, -68.0809909856513,
>     -66.2158721139987, -64.3507304088721, -62.4855705220364,
>     -60.6203959268265, -58.7552092693799, -56.8900126013571,
>     -55.0248075383117, -53.1595953700197, -51.2943771389511,
>     -49.429153697123, -47.5639257479787, -45.6986938777018,
>     -43.8334585789513, -41.9682202690754, -40.1029793042494,
>     -38.2377359905648, -36.3724905928122, -34.507243341501,
>     -32.6419944385177, -30.7767440617232, -28.9114923687178,
>     -27.0462394999448, -25.1809855812706, -23.3157307261409,
>     -21.4504750373982, -19.5852186088223, -17.7199615264474,
>     -15.8547038696949, -13.9894457123567, -12.1241871234558,
>     -10.2589281680064, -8.39366890769239, -6.52840940147998,
>     -4.66314970617789, -2.79788987695673, -0.932629967838005,
>     0.932629967838005, 2.79788987695673, 4.66314970617789, 6.52840940147998,
>     8.39366890769239, 10.2589281680064, 12.1241871234558, 13.9894457123567,
>     15.8547038696949, 17.7199615264474, 19.5852186088223, 21.4504750373982,
>     23.3157307261409, 25.1809855812706, 27.0462394999448, 28.9114923687178,
>     30.7767440617232, 32.6419944385177, 34.507243341501, 36.3724905928122,
>     38.2377359905648, 40.1029793042494, 41.9682202690754, 43.8334585789513,
>     45.6986938777018, 47.5639257479787, 49.429153697123, 51.2943771389511,
>     53.1595953700197, 55.0248075383117, 56.8900126013571, 58.7552092693799,
>     60.6203959268265, 62.4855705220364, 64.3507304088721, 66.2158721139987,
>     68.0809909856513, 69.9460806469834, 71.8111321142745, 73.6761323132091,
>     75.541061452879, 77.4058880820788, 79.2705590348597, 81.1349768376774,
>     82.9989416428375, 84.8619702920424, 86.7225309546681, 88.5721685140073 ;
>
>  longitude = 0, 1.875, 3.75, 5.625, 7.5, 9.375, 11.25, 13.125, 15, 16.875,
>     18.75, 20.625, 22.5, 24.375, 26.25, 28.125, 30, 31.875, 33.75, 35.625,
>     37.5, 39.375, 41.25, 43.125, 45, 46.875, 48.75, 50.625, 52.5, 54.375,
>     56.25, 58.125, 60, 61.875, 63.75, 65.625, 67.5, 69.375, 71.25, 73.125,
>     75, 76.875, 78.75, 80.625, 82.5, 84.375, 86.25, 88.125, 90, 91.875,
>     93.75, 95.625, 97.5, 99.375, 101.25, 103.125, 105, 106.875, 108.75,
>     110.625, 112.5, 114.375, 116.25, 118.125, 120, 121.875, 123.75, 125.625,
>     127.5, 129.375, 131.25, 133.125, 135, 136.875, 138.75, 140.625, 142.5,
>     144.375, 146.25, 148.125, 150, 151.875, 153.75, 155.625, 157.5, 159.375,
>     161.25, 163.125, 165, 166.875, 168.75, 170.625, 172.5, 174.375, 176.25,
>     178.125, 180, 181.875, 183.75, 185.625, 187.5, 189.375, 191.25, 193.125,
>     195, 196.875, 198.75, 200.625, 202.5, 204.375, 206.25, 208.125, 210,
>     211.875, 213.75, 215.625, 217.5, 219.375, 221.25, 223.125, 225, 226.875,
>     228.75, 230.625, 232.5, 234.375, 236.25, 238.125, 240, 241.875, 243.75,
>     245.625, 247.5, 249.375, 251.25, 253.125, 255, 256.875, 258.75, 260.625,
>     262.5, 264.375, 266.25, 268.125, 270, 271.875, 273.75, 275.625, 277.5,
>     279.375, 281.25, 283.125, 285, 286.875, 288.75, 290.625, 292.5, 294.375,
>     296.25, 298.125, 300, 301.875, 303.75, 305.625, 307.5, 309.375, 311.25,
>     313.125, 315, 316.875, 318.75, 320.625, 322.5, 324.375, 326.25, 328.125,
>     330, 331.875, 333.75, 335.625, 337.5, 339.375, 341.25, 343.125, 345,
>     346.875, 348.75, 350.625, 352.5, 354.375, 356.25, 358.125 ;
>
>  time = 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396, 424,
>     455, 485, 516, 546, 577, 608, 638, 669, 699, 730, 761, 790, 821, 851,
>     ..................................
>
> Jozef Syktus
> Principal Research Scientist
>
> Department of Natural Resources & Mines
> Climate Impacts and Natural Resource Systems
> QCCA Bldg. 80 Meiers Rd.
> Indooroopilly Qld 4068 Australia
> ---
> Phone:61 7 3896 9730
> Fax:  61 7 3896 9843
> e-mail:syktusj@nrm.qld.gov.au
> http://www.dnr.qld.gov.au
> ----
> Project:
> Dynamical Downscaling of Seasonal Climate Forecast
>
> ************************************************************************
> The information in this e-mail together with any attachments is
> intended only for the person or entity to which it is addressed
> and may contain confidential and/or privileged material.
> Any form of review, disclosure, modification, distribution
> and/or publication of this e-mail message is prohibited.
> If you have received this message in error, you are asked to
> inform the sender as quickly as possible and delete this message
> and any copies of this message from your computer and/or your
> computer system network.
> ************************************************************************

--
Ansley Manke  Pacific Marine Environmental Laboratory  Seattle WA




[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement