Regridding problem

Help
2013-12-09
2013-12-09
  • Maria Catala

    Maria Catala - 2013-12-09

    Hi everyone,

    I posted a question about regridding few days ago and thanks a lot to Henry for his answer.

    The use of ncap2 works perfectly for almost all my variables (Temperature, Geopotential height, relative humidity and vertical wind speed). Before regridding these variables I had to treat them: reverse latitude (which was N-> S), modify longitude (which was from 0 to 360 and not from -180 to 180) and delete the level dimension (my variables had 4 dimensions: time, longitude, latitude and level (which is the pressure level, size 1)).

    My problem comes from my variable called TCW (Total Column Water). For this variable the entire atmosphere is considered as a single layer so there is no level dimension. I just had to invert latitude and modify longitude.

    The regridding doesn't work, it gives a grid with random values from -20 000 to +20 000.
    This is what I obtain with the comparison (up: TCW before regridding, down: TCW after regridding, at the same timestep).

    alternate text

    Can someone help me?

    My code:

    Regrid.nco:

    // Bilinear interpolation

    defdim("latitude",13); // Define new dimension: latitude
    defdim("longitude",19); // Define new dimension: longitude
    latitude[$latitude] = {30, 32.5, 35, 37.5, 40, 42.5, 45, 47.5, 50, 52.5, 55, 57.5, 60};
    longitude[$longitude] = {-17.5, -15, -12.5, -10, -7.5, -5, -2.5, 0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20 ,22.5, 25, 27.5};

    out[$latitude,$longitude]=0.0; // Output structure

    // Bi-linear interpolation
    TCW[$time,$latitude,$longitude]=0.0;

    for( idx=0 ; idx<$time.size ; idx++){
    TCW(idx,:,:)=bilinear_interp(pr_wtr(idx,:,:),out,latitude,longitude,lat,lon);

    print(idx);
    }

    and after that: Interpol.sh

    #!/bin/bash
    # include Regrid.nco

    for fichier in /home/caillouet/Documents/Data/20Cr/TCW/*.nc
    do

    sfx=$( echo $fichier )
    out_name=$( basename $fichier .${fichier##*.} )

    #Invert latitude
    cdo invertlat $sfx out3.nc
    rm out2.nc

    Modify longitude
    ncap2 -O -s 'where(lon>180) lon=lon-360' out3.nc out4.nc
    rm out3.nc

    #Regridding
    ncap2 -v -S Regrid.nco out4.nc out5.nc
    rm out4.nc

    Then in the console I call the last file (./Interpol.sh)

    Thanks!

     
    Last edit: Maria Catala 2013-12-09
  • henry Butowsky

    henry Butowsky - 2013-12-09

    Hi Maria,
    I think the problem is with the "Modify longitude" step in Interpl.sh -
    the command " ncap2 -O -s 'where(lon>180) lon=lon-360' out3.nc out4.nc" only changes the values in lon and NOT the order
    All the variables which use the dimension "lon" (including var lon) need to be re-ordered. This can be achieved with a single ncks command. So we now have:

    // Modify longitude
    ncks -O --msa_usr_rdr -d lon,180.0,359.999 -d lon,0.0,179.999 out3.nc out4.nc
    ncap2 -O -s 'where(lon>180) lon=lon-360' out4.nc out5.nc
    rm out3.nc

    ... Henry

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks