BAS Main Index
  [Science]   [BAS home]   [Met home]   [WMC home] Antarctic Meteorology 


extra | A note on sea ice thickness

Ancil creation, and Converting between UKMO pp-format and ancillary file format

First and foremost, there is an UKMO program to do this job. But, I never worked out what namelists it wanted to read. So... use the below, if you wish, but be aware that its rather kludged and only there because I preferred to write my own rather than ask someone how the UKMO code worked...

Having said that, I regularly use the ancil utilities here to create ancil files, and you can too if you are careful.

Note: if things go horribly wrong, consider carefully the byteorder and machine type you are running this on. Big and Little Endian-ness and so on. I've got best results from Alphas or opterons. More on this here.

Note: some of the examples used here assume that you know something of IDL and the UKMO PP-format. If the latter is false, you're in trouble, because you'll need to create PP-fields in order to convert them... If the former is false, just "blip" over those bits: IDL is similar to fortran in many ways.

UKMO ancillary file -> PP file

This is the easy way round, because you can check the output is sensible.

You want (well, perhaps you don't, but you can use, if you're cautious) the script

wconv.pl

This is perl; it should work on all sane machines. If you don't know perl, you should: now is a good time to learn... Note that wconv.pl changes sometimes: a partial cvs list is: wconv.pl,v

To convert a file from ancil to pp, try:

wconv.pl qrclim.sst qrclim.sst.pp > wconv-sst.out

In this case, I've used the standard SST monthly fields that go into annually repeating runs. This is "easy". Then we can look at the SST fields, e.g.:

wmc> pp_list,'qrclim.sst.pp' ,/nat
   24    16   129  8888     0     1    16    96    73      0   0.0000 [ 2.71e+02, 3.03e+02], 2381
   24    16   129  8888     0     2    16    96    73      0   0.0000 [ 2.71e+02, 3.03e+02], 2381
   24    16   129  8888     0     3    16    96    73      0   0.0000 [ 2.71e+02, 3.03e+02], 2381
   24    16   129  8888     0     4    16    96    73      0   0.0000 [ 2.71e+02, 3.03e+02], 2381
   24    16   129  8888     0     5    16    96    73      0   0.0000 [ 2.71e+02, 3.03e+02], 2381
   24    16   129  8888     0     6    16    96    73      0   0.0000 [ 2.71e+02, 3.04e+02], 2381
   24    16   129  8888     0     7    16    96    73      0   0.0000 [ 2.71e+02, 3.05e+02], 2381
   24    16   129  8888     0     8    16    96    73      0   0.0000 [ 2.71e+02, 3.06e+02], 2381
   24    16   129  8888     0     9    16    96    73      0   0.0000 [ 2.71e+02, 3.05e+02], 2381
   24    16   129  8888     0    10    16    96    73      0   0.0000 [ 2.71e+02, 3.04e+02], 2381
   24    16   129  8888     0    11    16    96    73      0   0.0000 [ 2.71e+02, 3.03e+02], 2381
   24    16   129  8888     0    12    16    96    73      0   0.0000 [ 2.71e+02, 3.03e+02], 2381

wmc> a=get_field('qrclim.sst.pp',/nat,nf=12)

wmc> print,pp_guess_title(a)
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000
 lbexp: 0!CSurface surface temperature after timestep!Cday: 0000

wmc> print,pp_range(a)
      271.350      302.649
      271.350      302.639
      271.350      302.695
      271.350      303.091
      271.350      303.020
      271.350      304.361
      271.350      305.028
      271.350      305.857
      271.350      305.275
      271.350      304.137
      271.350      302.646
      271.350      302.923
And all seems plausible. Lets plot one, the first and last one:
pp_plot,a[0],ster=0,la=90,/blo,lev=indgen(30)-2 
gettwogifs,out='test-sst-1' 

pp_plot,a[11],ster=0,la=90,/blo,lev=indgen(30)-2
gettwogifs,out='test-sst-12'                    

They look OK. Good. Now onto the harder (and more useful) bit...

UKMO PP file -> ancillary file

Now, here is where it gets a bit tacky: we have more than one script, and I struggle to remember which is the best to use.

Here is an example that makes a waterfix ancil for the ocean: glen.pro.

Also, I can't make ancil fields from scratch: these scripts overwrite the contents of existing ancil files, which is much easier. It is possible (and tested to work) to overwrite an annually-repeating sst field with annually-varying values. It may in theory be possible to make, say, a soil moisture ancil by overwriting and sst ancil but I really don't recommend trying that unless you're desperate.

The scripts are:

  1. wunconv.pl (probably the safest to use for "easy" fields)
  2. [probably the one you want] wunconv2.pl (may well be required for making non-annually-repeating SST fields) (changes sometimes: you might want the CVS: wunconv2.pl,v)
  3. [prob best avoided] wunconv3.pl (unknown. try "diff")
  4. [prob best avoided] wunconv4.pl (ditto)

Lets make some fields to convert:

wmc> y=yc(a,/arr)
wmc> for i=0,11 do a[i].data=a[i].data+sind(y)
wmc> pp_write,a,'~/public/wmc/misc/ancil/qrclim-sst-1',/nat 
If all has gone well, these are the same as before plus a dependence on latitude.

Lets convert them to ancil (note that wunconv needs *3* files: an example header file for it to use as a skeleton; the pp-files you want inserted; and the output file):

wunconv.pl qrclim.sst qrclim-sst-1.pp qrclim.sst.1 > wunconv-sst.out
OK, fine. That seemed to go ok. But (other than running the model on the file) its hard to tell. So, lets re-convert:
wconv.pl qrclim.sst.1 qrclim-sst-1-reconv.pp
Now we read it into IDL:
wmc> b=get_field('~/public/wmc/misc/ancil/qrclim-sst-1-reconv.pp',/nat,nf=12)
wmc> a=get_field('~/public/wmc/misc/ancil/qrclim.sst.pp',/nat,nf=12)         
wmc> pp_plot,pp_diff(a[11],b[11]),la=90,ster=0,lev=indgen(21)/10.-1,/blo

This seems to be OK:

If you find you need wunconv2.pl, then the following example might help (thanks Tom):

wunconv2.pl N_ins=120 DATE=1957 ENDDATE=1989 FIXHD10=1 ancil_file pp_file output_ancil_file
where
  1. N_ins - number of fields
  2. Date - Start year
  3. ENDDATE - end year
  4. FIXHD10 - 0-single field 1-timeseries 2-repeating
The following sometimes helps, too, if you need to change the start date of the model to something different to the start dump:
> You will need to add the following lines to the namelist 
> HEADERS under the line FIXHD(12)=404, 
> 
> FIXHD(21)=1996, 
> FIXHD(22)=12, 
> FIXHD(23)=1, 
> FIXHD(28)=1996, 
> FIXHD(29)=12, 
> FIXHD(30)=1, 
>
> a perl script to do the editing can be found: cs.pl. The model can then be submitted and it may work! 


Past last modified: 27/6/2005

wmc@bas.ac.uk     © Copyright Natural Environment Research Council - British Antarctic Survey 2001