adding perturbation to certain variables

Help
mark
2014-07-10
2014-07-16
  • mark
    mark
    2014-07-10

    Hello,
    The first file contains perturbations to certain variables. The second file contains the corresponding variables and also some other variables that should remain unperturbed.
    I have been trying add perturbations with ncbo but it fails. I would like to save on IO since files are large. Should I first extract the selected variables from the second file, add perturbations to them and do ncks -A with this file and the original "second file". What is the best way to do it?
    Thanks,
    Mark

    %ncdump -h aerodiff_006

    netcdf aerodiff_006 {
    dimensions:
    Time = UNLIMITED ; // (1 currently)
    bottom_top = 40 ;
    south_north = 122 ;
    west_east = 112 ;

    %ncdump -h wrfinput_enkf_d01_2012-06-01_06:00:00

    netcdf wrfinput_enkf_d01_2012-06-01_06\:00\:00 {
    dimensions:
    Time = UNLIMITED ; // (1 currently)
    DateStrLen = 19 ;
    west_east = 112 ;
    south_north = 122 ;
    bottom_top = 40 ;
    bottom_top_stag = 41 ;
    soil_layers_stag = 4 ;
    west_east_stag = 113 ;
    south_north_stag = 123 ;
    DIM0009 = 5 ;
    land_cat_stag = 20 ;
    soil_cat_stag = 16 ;
    snso_layers_stag = 7 ;
    snow_layers_stag = 3 ;
    dust_erosion_dimension = 3 ;
    klevs_for_fire = 1 ;

    %ncbo --op_typ='+' aerodiff_006 wrfinput_enkf_d01_2012-06-01_06:00:00 file3.nc

    ncbo: ERROR dimension "DateStrLen" in second file wrfinput_enkf_d01_2012-06-01_06:00:00 is not present in first file aerodiff_006

     
    • mark
      mark
      2014-07-10

      It seems the best I can do is

      ncbo -op_typ='+' -v $vars aerodiff_006 wrfinput_enkf_d01_2012-06-01_06:00:00 file3.nc

      ncks -A file3.nc wrfinput_enkf_d01_2012-06-01_06:00:00

       
  • Charlie Zender
    Charlie Zender
    2014-07-10

    Try combining appending with ncbo in one command like this:

    ncbo -A --op_typ='+' aerodiff_006 wrfinput_enkf_d01_2012-06-01_06:00:00 file3.nc

     
  • mark
    mark
    2014-07-10

    with the 4.4.4/gny/4.4.7 it only outputs to file3.nc variables that are present in aerodiff_006

     
  • Charlie Zender
    Charlie Zender
    2014-07-10

    Oops, of course the command should be this:

    cp wrfinput_enkf_d01_2012-06-01_06:00:00 file3.nc
    ncbo -A --op_typ='+' aerodiff_006 file3.nc file3.nc

     
    • mark
      mark
      2014-07-14

      There is one more thing that came up. Is it possible with this one-liner also to set all variables to a certain minimum value if they fall below a threshold (0.)?
      Alternatively, I think, that would need to be done with ncap2 using -s 'where ...'
      for each variable?

       
  • mark
    mark
    2014-07-10

    Thanks, that works perfect

     
  • Charlie Zender
    Charlie Zender
    2014-07-16

    re: your most recent question, setting values to a new value according to a threshold is best done with ncap2, as you suggest. unfortunately this means one must loop over all variables manually.
    cz