Changeset 81

Show
Ignore:
Timestamp:
11/24/08 04:44:31 (3 months ago)
Author:
ros
Message:

#39 Fix check on units attribute for coordinate variables.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • cf-checker/trunk/src/cfchecks.py

    r55 r81  
    99# Date: February 2003 
    1010# 
    11 # Version: 1.10 
     11# File Revision: $Revision$ 
     12
     13# CF Checker Version: 1.10 
    1214# 
    1315#------------------------------------------------------------- 
    14 ''' cfchecker [-s|--cf_standard_names standard_names.xml] [-u|--udunits udunits.dat] file1 [file2...] 
     16''' cfchecker [-s|--cf_standard_names standard_names.xml] [-u|--udunits udunits.dat] [-v|--version CFVersion] file1 [file2...] 
    1517 
    1618Description: 
     
    2628 -h or --help: Prints this help text. 
    2729 
     30 -v or --version: CF version to check against. 
     31 
    2832''' 
    2933 
     
    3640STANDARDNAME="./standard_name.xml" 
    3741checkerVersion="1.10" 
    38 CFVersions=['CF-1.0','CF-1.1'
    39 Versions=[1.0,1.1
     42CFVersions=['CF-1.0','CF-1.1','CF-1.2'
     43Versions=[1.0,1.1,1.2
    4044 
    4145#----------------------------------------------------------- 
     
    238242    allCoordVars=coordVars[:] 
    239243    allCoordVars[len(allCoordVars):]=auxCoordVars[:] 
     244 
    240245    self.setUpFormulas() 
     246     
    241247    axes=self.f.axes.keys() 
    242248 
     
    599605                    self.err = self.err+1 
    600606 
    601         #------------------------------------------ 
     607        #-----------------------x1------------------- 
    602608        # Is there a grid_mapping variable? 
    603609        #------------------------------------------ 
     
    631637                        'stereographic','transverse_mercator'] 
    632638           
     639          if self.version >= 1.2: 
     640              # Extra grid_mapping_names at vn1.2 
     641              validNames[len(validNames):] = ['latitude_longitude','vertical_perspective'] 
     642 
    633643          if var.grid_mapping_name not in validNames: 
    634644              print "ERROR (5.6): Invalid grid_mapping_name:",var.grid_mapping_name 
     
    685695                                                      ,'f(j,i)=0.5*(z1+z2)+0.5*(z1-z2)*tanh(2*a/(z1-z2)*(depth(j,i)-href))'] 
    686696 
    687  
     697       
    688698  #---------------------------------------- 
    689699  def parseBlankSeparatedList(self, list): 
     
    710720 
    711721        if conventions != 'CF-'+str(self.version): 
    712             print "WARNING: Inconsistency - The conventions attribute is set to "+conventions+", but you've requested a validity check against CF version",self.version 
     722            print "WARNING: Inconsistency - The conventions attribute is set to "+conventions+", but you've requested a validity check against CF",self.version 
    713723            self.warn = self.warn+1 
    714724             
     
    11431153      rc=1 
    11441154      var=self.f[varName] 
    1145  
     1155       
    11461156      if self.badc: 
    11471157          rc = self.chkBADCUnits(var) 
     
    11501160              return rc 
    11511161 
    1152       if var.attributes.has_key('units'): 
     1162      # Test for blank since coordinate variables have 'units' defined even if not specifically defined in the file 
     1163      if var.attributes.has_key('units') and var.attributes['units'] != '': 
    11531164          # Type of units is a string 
    11541165          units = var.attributes['units'] 
     
    12191230                          print "WARNING (3.1): units attribute should be present" 
    12201231                          self.warn = self.warn+1 
    1221                       elif not var.attributes.has_key('positive') and not var.attributes.has_key('formula_terms'): 
    1222                           print "WARNING (3.1): units attribute should be present" 
    1223                           self.warn = self.warn+1 
     1232                  elif not var.attributes.has_key('positive') and not var.attributes.has_key('formula_terms'): 
     1233                      print "WARNING (3.1): units attribute should be present" 
     1234                      self.warn = self.warn+1 
    12241235                 
    12251236      return rc 
  • cf-checker/trunk/test_files/CF_1_0_OK.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77 
  • cf-checker/trunk/test_files/CRM018_test1.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (2.6.1): No 'Conventions' attribute present 
  • cf-checker/trunk/test_files/CRM021_test1.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77 
  • cf-checker/trunk/test_files/CRM024_test1.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77ERROR (2.6.1): This netCDF file does not appear to contain CF Convention data. 
    8 WARNING: Inconsistency - The conventions attribute is set to CF1.0, but you've requested a validity check against CF version 1.0 
     8WARNING: Inconsistency - The conventions attribute is set to CF1.0, but you've requested a validity check against CF 1.0 
    99ERROR (5.6): MSLP - Invalid syntax for 'grid_mapping' attribute 
    1010 
     
    3232------------------ 
    3333WARNING (3): No standard_name or long_name attribute specified 
     34WARNING (3.1): units attribute should be present 
    3435 
    3536ERRORS detected: 2 
    36 WARNINGS given: 5 
     37WARNINGS given: 6 
  • cf-checker/trunk/test_files/CRM026_test2.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77 
  • cf-checker/trunk/test_files/CRM027_test1.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (7.1): Data for variable time lies outside cell boundaries 
  • cf-checker/trunk/test_files/CRM027_test2.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (7.1): Data for variable time lies outside cell boundaries 
  • cf-checker/trunk/test_files/CRM028_test1.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (2.6.1): No 'Conventions' attribute present 
  • cf-checker/trunk/test_files/CRM032_test1.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77ERROR (2.6.1): This netCDF file does not appear to contain CF Convention data. 
    8 WARNING: Inconsistency - The conventions attribute is set to CF1.0, but you've requested a validity check against CF version 1.0 
     8WARNING: Inconsistency - The conventions attribute is set to CF1.0, but you've requested a validity check against CF 1.0 
    99ERROR (5.6): MSLP - Invalid syntax for 'grid_mapping' attribute 
    1010 
     
    3232Checking variable: rgrid 
    3333------------------ 
    34 ERROR (3.1): Units are not consistent with those given in the standard_name table. 
     34WARNING (3.1): units attribute should be present 
    3535ERROR (8.2): values of rgrid must be in the range 0 to 14639 
    3636ERROR (5): co-ordinate variable 'rgrid' not monotonic 
    3737 
    38 ERRORS detected: 6 
    39 WARNINGS given: 4 
     38ERRORS detected: 5 
     39WARNINGS given: 5 
  • cf-checker/trunk/test_files/CRM033_test1.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (2.6.1): No 'Conventions' attribute present 
  • cf-checker/trunk/test_files/CRM035.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (2.6.1): No 'Conventions' attribute present 
  • cf-checker/trunk/test_files/CRM037.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77 
  • cf-checker/trunk/test_files/CRM038.check

    r54 r81  
     1ncvarget: ncid 4; varid 0: Index exceeds dimension bound 
    12 
    23CHECKING NetCDF FILE: CRM038.nc 
    34===================== 
    45Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     6Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    67 
    78 
     
    1314Checking variable: xc 
    1415------------------ 
     16WARNING (3.1): units attribute should be present 
    1517ERROR (5): co-ordinate variable 'xc' not monotonic 
    1618 
     
    1820Checking variable: yc 
    1921------------------ 
     22WARNING (3.1): units attribute should be present 
    2023ERROR (5): co-ordinate variable 'yc' not monotonic 
    2124 
     
    3740 
    3841ERRORS detected: 2 
    39 WARNINGS given: 0 
     42WARNINGS given: 2 
  • cf-checker/trunk/test_files/CRM041.check

    r54 r81  
     1ncvarget: ncid 4; varid 0: Index exceeds dimension bound 
    12 
    23CHECKING NetCDF FILE: CRM041.nc 
    34===================== 
    45Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     6Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    67 
    78 
  • cf-checker/trunk/test_files/GregRappa.check

    r56 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77 
  • cf-checker/trunk/test_files/Trac020_test1.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77 
  • cf-checker/trunk/test_files/Trac020_test2.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77 
  • cf-checker/trunk/test_files/Trac022.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (2.6.1): No 'Conventions' attribute present 
  • cf-checker/trunk/test_files/UpgradeVn.pl

    r54 r81  
    1515#--------------------------------------------------------------------------  
    1616$checkerVN="1.10"; 
    17 $standardNameVN="7 (2007-11-20T02:00:00Z)"; 
     17$standardNameVN="11 (2008-11-11T11:00:00Z)"; 
    1818 
    19 $TEST_FILES_DIR="/home/ros/SRCE_projects/CF_Checker_W/main/Test_Files"; 
     19$TEST_FILES_DIR="/home/ros/cf-checker/trunk/test_files"; 
    2020chdir $TEST_FILES_DIR or die "Failed to cd to $TEST_FILES_DIR: $!\n"; 
    2121 
  • cf-checker/trunk/test_files/badc_units.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (7.1): Data for variable time lies outside cell boundaries 
  • cf-checker/trunk/test_files/cell_measures.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77ERROR (7.1): Incorrect dimensions for boundary variable: lon_vertices 
  • cf-checker/trunk/test_files/cell_methods.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77ERROR (7.1): Incorrect dimensions for boundary variable: lon_vertices 
  • cf-checker/trunk/test_files/complex.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77Warning: bounds variable not found in complex.nc: bounds_lat2d 
     
    4747------------------ 
    4848WARNING (3): No standard_name or long_name attribute specified 
    49 ERROR (4): Axis attribute is not allowed for auxillary coordinate variables. 
    5049 
    5150------------------ 
     
    7675------------------ 
    7776WARNING (3): No standard_name or long_name attribute specified 
     77WARNING (3.1): units attribute should be present 
    7878 
    7979------------------ 
     
    9898------------------ 
    9999WARNING (3): No standard_name or long_name attribute specified 
     100WARNING (3.1): units attribute should be present 
    100101 
    101102------------------ 
     
    112113------------------ 
    113114 
    114 ERRORS detected: 7 
    115 WARNINGS given: 14 
     115ERRORS detected: 6 
     116WARNINGS given: 16 
  • cf-checker/trunk/test_files/formula_terms.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77WARNING (7.1): Data for variable lat lies outside cell boundaries 
  • cf-checker/trunk/test_files/hfogo_O1_labelVariable_KT.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 11 (2008-11-11T11:00:00Z) 
    66 
    77 
  • cf-checker/trunk/test_files/stdName_test.check

    r54 r81  
    33===================== 
    44Using CF Checker version 1.10 
    5 Using Standard Name Table Version 7 (2007-11-20T02:00:00Z) 
     5Using Standard Name Table Version 2 (2006-09-26T18:12:43Z) 
    66 
     7WARNING: Inconsistency - The conventions attribute is set to CF-1.0, but you've requested a validity check against CF 1.2 
    78ERROR (7.1): Boundary var time_bnds has inconsistent std_name to time 
    89WARNING (7.1): Data for variable time lies outside cell boundaries 
     
    3536 
    3637ERRORS detected: 3 
    37 WARNINGS given: 1 
     38WARNINGS given: 2 
  • cf-checker/trunk/test_files/tests.sh

    r38 r81  
    77mkdir $outdir 
    88 
     9export PYTHONPATH=/home/ros/software/python/cdat-lite:/home/ros/software/python/udunits 
     10std_name_table=http://cf-pcmdi.llnl.gov/documents/cf-standard-names/current/cf-standard-name-table.xml 
    911for file in `ls *.nc` 
    1012do 
     
    1214  then 
    1315    # Check --badc option (Note:  Need to set path to badc_units.txt in cfchecks.py) 
    14     ../src/cfchecks.py --badc $file > $outdir/$file.out 2>&1 
     16    ../src/cfchecks.py --badc $file -s $std_name_table > $outdir/$file.out 2>&1 
    1517  elif test $file == "stdName_test.nc" 
    1618  then 
    1719    # Check --cf_standard_names option 
    1820    ../src/cfchecks.py --cf_standard_names ./stdName_test_table.xml $file > $outdir/$file.out 2>&1 
     21  elif test $file == "CF_1_2.nc" 
     22  then 
     23    # CF-1.2 
     24    ../src/cfchecks.py -s $std_name_table -v 1.2 $file > $outdir/$file.out 2>&1 
    1925  else 
    2026    # Run the checker on the file 
    21     ../src/cfchecks.py $file > $outdir/$file.out 2>&1 
     27    ../src/cfchecks.py -s $std_name_table -v 1.0 $file > $outdir/$file.out 2>&1 
    2228  fi 
    2329  # Check the output against what is expected