[ncl-talk] A suggestion for reading variable from multiply files with different units.
Dennis Shea
shea at ucar.edu
Wed Oct 8 09:49:08 MDT 2014
THX for the suggestion. However, the addfiles function was developed to
allow
a heterogeneous (non-uniform) set of files to be accomodated. EG:
netCDF/GRIB/HDF
could all be accessed. The CMIP files are all CF compliant so there is some
consistency.
Other file formats (HDF) may or may not have a units attribute.
You could develop your own function [ untested ]
undef("check_units_att")
function check_units_att(f:list, varName[1]:string)
local nfils, units, nf, units_0, same_units, units_nf
begin
nfils = ListCount(f)
;units= new(nfils,"string") ; optional
nf = 0
if (isfilevaratt(f[nf], varName, "units")) then
units_0 = f[nf]->$varName$@units ; initial units
;units(nf) = units_0
else
print("check_units_att: no units attribute: "+varName+": FATAL")
exit
end if
same_units = True
do nf=1,nfils-1
if (isfilevaratt(f[nf], varName, "units")) then
units_nf = f[nf]->$varName$@units
;units(nf) = units_nf
if (units_nf .ne. units_0) then
;print("units_0="+units_0+" : units_nf="+units_nf)
same_units = False
end if
else
print("check_units_att: no units attribute: nf="+nf)
end if
end do
;same_units at var_units = units
return(same_units)
end
On Tue, Oct 7, 2014 at 5:47 PM, Ping Huang <ph0007 at ustc.edu> wrote:
> Dear NCL developers,
>
> I have a suggestion for reading variable from multiply files with
> different units, like xxx = infile[:]->yyy.
>
> Because of the constraint that one variable only has one unit, the unit in
> the first file is read in as the unit of input variable when reading
> multiply files.
>
> Usually, there is no problem because the multiply files from same source
> often have same unit. However, when the units in the files are different,
> for example the units of time in some CMIP5 model outputs, the input unit
> does not match with the data in other files.
>
> So, I suggest when reading multiply files the identity of all units should
> be checked. If the units are not identical, a warning should be given.
>
> Best,
>
> Ping Huang
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20141008/7353b525/attachment.html
More information about the ncl-talk
mailing list