Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

How to invert Latitude data 90S:90N

Mubashar
2013-07-16
2013-10-17
  • Mubashar
    Mubashar
    2013-07-16

    Dear NCO users,

    I have a data in netcdf file at fixed longitude but latitude varies from 90S:90 N with 40 Z levels. I wanted to use this data just by inverting latitude values. I mean 0:90 N should correspond to 0:90 S and similarly data at 0:90 S should correspond to 0:90 N.

    In short the entire 90S:90N should be inverted. Is it possible to do that using NCO.

    Thanks,

    Mubashar

     
  • Charlie Zender
    Charlie Zender
    2013-07-16

    this reverses the latitude dimension:

    ncpdq -a '-lat' in.nc out.nc

     
  • Mubashar
    Mubashar
    2013-07-17

    Dear Zender,

    It doesn't change the latitude. The latitude for input and output files remain the same. Can I attach file for any one time step for you to have a look?

    Thanks,

    Mubashar

     
  • Charlie Zender
    Charlie Zender
    2013-07-17

    here's an example showing how this works:
    zender@roulee:~/nco/bld$ ncks -C -H -v lat ~/nco/data/in.nc
    lat=-90
    lat=90

    zender@roulee:~/nco/bld$ ncpdq -O -a -lat -v lat ~/nco/data/in.nc ~/foo.nc
    zender@roulee:~/nco/bld$ ncks -C -H -v lat ~/foo.nc
    lat=90
    lat=-90

     
  • Mubashar
    Mubashar
    2013-07-18

    Dear Prof. It seems that data for the variable at the given latitude is not inverted along with it. I want the data for all the variable for input file to be changed accordingly. Let say my Temperature variable value corresponding to 90S should go to 90N and so on for all the latitudes and all the variables.

    Thanks,

    Mubashar

     
  • Charlie Zender
    Charlie Zender
    2013-07-18

    Stare at this. It shows that ncpdq reverses latitude and all data associated with it.
    If you want to create a sci-fi world where northern latitudes have southern temperatures,
    simply replace the latitude array by its reverse using ncpdq to reverse and ncks to replace.

    zender@roulee:~/nco/bld$ ncks -C -u -v three_dmn_rec_var ~/nco/data/in.nc
    three_dmn_rec_var: type NC_FLOAT, 3 dimensions, 2 attributes, chunked? no, compressed? no, packed? no
    three_dmn_rec_var size (RAM) = 10*2*4*sizeof(NC_FLOAT) = 80*4 = 320 bytes
    three_dmn_rec_var dimension 0: time, size = 10 NC_DOUBLE (Record coordinate is time)
    three_dmn_rec_var dimension 1: lat, size = 2 NC_FLOAT (Coordinate is lat)
    three_dmn_rec_var dimension 2: lon, size = 4 NC_FLOAT (Coordinate is lon)
    three_dmn_rec_var attribute 0: long_name, size = 33 NC_CHAR, value = three dimensional record variable
    three_dmn_rec_var attribute 1: units, size = 12 NC_CHAR, value = watt meter-2

    time=1 lat=-90 lon=0 three_dmn_rec_var=1
    time=1 lat=-90 lon=90 three_dmn_rec_var=2
    time=1 lat=-90 lon=180 three_dmn_rec_var=3
    time=1 lat=-90 lon=270 three_dmn_rec_var=4
    time=1 lat=90 lon=0 three_dmn_rec_var=5
    time=1 lat=90 lon=90 three_dmn_rec_var=6
    time=1 lat=90 lon=180 three_dmn_rec_var=7
    time=1 lat=90 lon=270 three_dmn_rec_var=8
    time=2 lat=-90 lon=0 three_dmn_rec_var=9
    time=2 lat=-90 lon=90 three_dmn_rec_var=10
    time=2 lat=-90 lon=180 three_dmn_rec_var=11
    time=2 lat=-90 lon=270 three_dmn_rec_var=12
    time=2 lat=90 lon=0 three_dmn_rec_var=13
    time=2 lat=90 lon=90 three_dmn_rec_var=14
    time=2 lat=90 lon=180 three_dmn_rec_var=15
    time=2 lat=90 lon=270 three_dmn_rec_var=16
    time=3 lat=-90 lon=0 three_dmn_rec_var=17
    time=3 lat=-90 lon=90 three_dmn_rec_var=18
    time=3 lat=-90 lon=180 three_dmn_rec_var=19
    time=3 lat=-90 lon=270 three_dmn_rec_var=20
    time=3 lat=90 lon=0 three_dmn_rec_var=21
    time=3 lat=90 lon=90 three_dmn_rec_var=22
    time=3 lat=90 lon=180 three_dmn_rec_var=23
    time=3 lat=90 lon=270 three_dmn_rec_var=24
    time=4 lat=-90 lon=0 three_dmn_rec_var=25
    time=4 lat=-90 lon=90 three_dmn_rec_var=26
    time=4 lat=-90 lon=180 three_dmn_rec_var=27
    time=4 lat=-90 lon=270 three_dmn_rec_var=28
    time=4 lat=90 lon=0 three_dmn_rec_var=29
    time=4 lat=90 lon=90 three_dmn_rec_var=30
    time=4 lat=90 lon=180 three_dmn_rec_var=31
    time=4 lat=90 lon=270 three_dmn_rec_var=32
    time=5 lat=-90 lon=0 three_dmn_rec_var=33
    time=5 lat=-90 lon=90 three_dmn_rec_var=34
    time=5 lat=-90 lon=180 three_dmn_rec_var=35
    time=5 lat=-90 lon=270 three_dmn_rec_var=36
    time=5 lat=90 lon=0 three_dmn_rec_var=37
    time=5 lat=90 lon=90 three_dmn_rec_var=38
    time=5 lat=90 lon=180 three_dmn_rec_var=39
    time=5 lat=90 lon=270 three_dmn_rec_var=40
    time=6 lat=-90 lon=0 three_dmn_rec_var=41
    time=6 lat=-90 lon=90 three_dmn_rec_var=42
    time=6 lat=-90 lon=180 three_dmn_rec_var=43
    time=6 lat=-90 lon=270 three_dmn_rec_var=44
    time=6 lat=90 lon=0 three_dmn_rec_var=45
    time=6 lat=90 lon=90 three_dmn_rec_var=46
    time=6 lat=90 lon=180 three_dmn_rec_var=47
    time=6 lat=90 lon=270 three_dmn_rec_var=48
    time=7 lat=-90 lon=0 three_dmn_rec_var=49
    time=7 lat=-90 lon=90 three_dmn_rec_var=50
    time=7 lat=-90 lon=180 three_dmn_rec_var=51
    time=7 lat=-90 lon=270 three_dmn_rec_var=52
    time=7 lat=90 lon=0 three_dmn_rec_var=53
    time=7 lat=90 lon=90 three_dmn_rec_var=54
    time=7 lat=90 lon=180 three_dmn_rec_var=55
    time=7 lat=90 lon=270 three_dmn_rec_var=56
    time=8 lat=-90 lon=0 three_dmn_rec_var=57
    time=8 lat=-90 lon=90 three_dmn_rec_var=58
    time=8 lat=-90 lon=180 three_dmn_rec_var=59
    time=8 lat=-90 lon=270 three_dmn_rec_var=60
    time=8 lat=90 lon=0 three_dmn_rec_var=61
    time=8 lat=90 lon=90 three_dmn_rec_var=62
    time=8 lat=90 lon=180 three_dmn_rec_var=63
    time=8 lat=90 lon=270 three_dmn_rec_var=64
    time=9 lat=-90 lon=0 three_dmn_rec_var=65
    time=9 lat=-90 lon=90 three_dmn_rec_var=66
    time=9 lat=-90 lon=180 three_dmn_rec_var=67
    time=9 lat=-90 lon=270 three_dmn_rec_var=68
    time=9 lat=90 lon=0 three_dmn_rec_var=69
    time=9 lat=90 lon=90 three_dmn_rec_var=70
    time=9 lat=90 lon=180 three_dmn_rec_var=71
    time=9 lat=90 lon=270 three_dmn_rec_var=72
    time=10 lat=-90 lon=0 three_dmn_rec_var=73
    time=10 lat=-90 lon=90 three_dmn_rec_var=74
    time=10 lat=-90 lon=180 three_dmn_rec_var=75
    time=10 lat=-90 lon=270 three_dmn_rec_var=76
    time=10 lat=90 lon=0 three_dmn_rec_var=77
    time=10 lat=90 lon=90 three_dmn_rec_var=78
    time=10 lat=90 lon=180 three_dmn_rec_var=79
    time=10 lat=90 lon=270 three_dmn_rec_var=80

    zender@roulee:~/nco/bld$ ncks -C -u -v three_dmn_rec_var ~/foo.nc
    three_dmn_rec_var: type NC_FLOAT, 3 dimensions, 2 attributes, chunked? no, compressed? no, packed? no
    three_dmn_rec_var size (RAM) = 10*2*4*sizeof(NC_FLOAT) = 80*4 = 320 bytes
    three_dmn_rec_var dimension 0: time, size = 10 NC_DOUBLE (Record coordinate is time)
    three_dmn_rec_var dimension 1: lat, size = 2 NC_FLOAT (Coordinate is lat)
    three_dmn_rec_var dimension 2: lon, size = 4 NC_FLOAT (Coordinate is lon)
    three_dmn_rec_var attribute 0: long_name, size = 33 NC_CHAR, value = three dimensional record variable
    three_dmn_rec_var attribute 1: units, size = 12 NC_CHAR, value = watt meter-2

    time=1 lat=90 lon=0 three_dmn_rec_var=5
    time=1 lat=90 lon=90 three_dmn_rec_var=6
    time=1 lat=90 lon=180 three_dmn_rec_var=7
    time=1 lat=90 lon=270 three_dmn_rec_var=8
    time=1 lat=-90 lon=0 three_dmn_rec_var=1
    time=1 lat=-90 lon=90 three_dmn_rec_var=2
    time=1 lat=-90 lon=180 three_dmn_rec_var=3
    time=1 lat=-90 lon=270 three_dmn_rec_var=4
    time=2 lat=90 lon=0 three_dmn_rec_var=13
    time=2 lat=90 lon=90 three_dmn_rec_var=14
    time=2 lat=90 lon=180 three_dmn_rec_var=15
    time=2 lat=90 lon=270 three_dmn_rec_var=16
    time=2 lat=-90 lon=0 three_dmn_rec_var=9
    time=2 lat=-90 lon=90 three_dmn_rec_var=10
    time=2 lat=-90 lon=180 three_dmn_rec_var=11
    time=2 lat=-90 lon=270 three_dmn_rec_var=12
    time=3 lat=90 lon=0 three_dmn_rec_var=21
    time=3 lat=90 lon=90 three_dmn_rec_var=22
    time=3 lat=90 lon=180 three_dmn_rec_var=23
    time=3 lat=90 lon=270 three_dmn_rec_var=24
    time=3 lat=-90 lon=0 three_dmn_rec_var=17
    time=3 lat=-90 lon=90 three_dmn_rec_var=18
    time=3 lat=-90 lon=180 three_dmn_rec_var=19
    time=3 lat=-90 lon=270 three_dmn_rec_var=20
    time=4 lat=90 lon=0 three_dmn_rec_var=29
    time=4 lat=90 lon=90 three_dmn_rec_var=30
    time=4 lat=90 lon=180 three_dmn_rec_var=31
    time=4 lat=90 lon=270 three_dmn_rec_var=32
    time=4 lat=-90 lon=0 three_dmn_rec_var=25
    time=4 lat=-90 lon=90 three_dmn_rec_var=26
    time=4 lat=-90 lon=180 three_dmn_rec_var=27
    time=4 lat=-90 lon=270 three_dmn_rec_var=28
    time=5 lat=90 lon=0 three_dmn_rec_var=37
    time=5 lat=90 lon=90 three_dmn_rec_var=38
    time=5 lat=90 lon=180 three_dmn_rec_var=39
    time=5 lat=90 lon=270 three_dmn_rec_var=40
    time=5 lat=-90 lon=0 three_dmn_rec_var=33
    time=5 lat=-90 lon=90 three_dmn_rec_var=34
    time=5 lat=-90 lon=180 three_dmn_rec_var=35
    time=5 lat=-90 lon=270 three_dmn_rec_var=36
    time=6 lat=90 lon=0 three_dmn_rec_var=45
    time=6 lat=90 lon=90 three_dmn_rec_var=46
    time=6 lat=90 lon=180 three_dmn_rec_var=47
    time=6 lat=90 lon=270 three_dmn_rec_var=48
    time=6 lat=-90 lon=0 three_dmn_rec_var=41
    time=6 lat=-90 lon=90 three_dmn_rec_var=42
    time=6 lat=-90 lon=180 three_dmn_rec_var=43
    time=6 lat=-90 lon=270 three_dmn_rec_var=44
    time=7 lat=90 lon=0 three_dmn_rec_var=53
    time=7 lat=90 lon=90 three_dmn_rec_var=54
    time=7 lat=90 lon=180 three_dmn_rec_var=55
    time=7 lat=90 lon=270 three_dmn_rec_var=56
    time=7 lat=-90 lon=0 three_dmn_rec_var=49
    time=7 lat=-90 lon=90 three_dmn_rec_var=50
    time=7 lat=-90 lon=180 three_dmn_rec_var=51
    time=7 lat=-90 lon=270 three_dmn_rec_var=52
    time=8 lat=90 lon=0 three_dmn_rec_var=61
    time=8 lat=90 lon=90 three_dmn_rec_var=62
    time=8 lat=90 lon=180 three_dmn_rec_var=63
    time=8 lat=90 lon=270 three_dmn_rec_var=64
    time=8 lat=-90 lon=0 three_dmn_rec_var=57
    time=8 lat=-90 lon=90 three_dmn_rec_var=58
    time=8 lat=-90 lon=180 three_dmn_rec_var=59
    time=8 lat=-90 lon=270 three_dmn_rec_var=60
    time=9 lat=90 lon=0 three_dmn_rec_var=69
    time=9 lat=90 lon=90 three_dmn_rec_var=70
    time=9 lat=90 lon=180 three_dmn_rec_var=71
    time=9 lat=90 lon=270 three_dmn_rec_var=72
    time=9 lat=-90 lon=0 three_dmn_rec_var=65
    time=9 lat=-90 lon=90 three_dmn_rec_var=66
    time=9 lat=-90 lon=180 three_dmn_rec_var=67
    time=9 lat=-90 lon=270 three_dmn_rec_var=68
    time=10 lat=90 lon=0 three_dmn_rec_var=77
    time=10 lat=90 lon=90 three_dmn_rec_var=78
    time=10 lat=90 lon=180 three_dmn_rec_var=79
    time=10 lat=90 lon=270 three_dmn_rec_var=80
    time=10 lat=-90 lon=0 three_dmn_rec_var=73
    time=10 lat=-90 lon=90 three_dmn_rec_var=74
    time=10 lat=-90 lon=180 three_dmn_rec_var=75
    time=10 lat=-90 lon=270 three_dmn_rec_var=76