[cmor] 17/190: 2010-05-28 : reverted file name construction to use first/last time. BUT added precision for daily and higher frequencies 2010-05-28 : fixed a bug in cmor checker when variable entry was "pop" would break 2010-05-28 : fixed default values of noerror in script from True to cmor.CMOR_CRITICAL

Alastair McKinstry mckinstry at moszumanska.debian.org
Tue Jul 21 12:54:20 UTC 2015


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to branch debian/master
in repository cmor.

commit 147b07ceb0a19eed8a8cc3b164ebeadbb3bc2349
Author: Charles Doutriaux <doutriaux1 at llnl.gov>
Date:   Fri May 28 11:00:57 2010 -0700

    2010-05-28 : reverted file name construction to use first/last time. BUT added precision for daily and higher frequencies
    2010-05-28 : fixed a bug in cmor checker when variable entry was "pop" would break
    2010-05-28 : fixed default values of noerror in script from True to cmor.CMOR_CRITICAL
---
 Lib/check_CMOR_compliant.py | 58 ++++++++++++++++++++++-----------------------
 RELEASE-NOTES               |  3 +++
 Src/cmor.c                  | 56 +++++++++++++++++++++----------------------
 Src/cmor_variables.c        | 38 ++++++++++++++---------------
 include/cmor.h              |  4 ++--
 5 files changed, 80 insertions(+), 79 deletions(-)

diff --git a/Lib/check_CMOR_compliant.py b/Lib/check_CMOR_compliant.py
index eee8bec..f1d8069 100644
--- a/Lib/check_CMOR_compliant.py
+++ b/Lib/check_CMOR_compliant.py
@@ -143,7 +143,8 @@ def readTable(table):
         entry=sp[1].strip()
         if not e.has_key(entry_type):
             e[entry_type]={}
-        e[entry_type][entry]=getattr(e[entry_type],entry,{})
+        e[entry_type][entry]=e[entry_type].get(entry,{})
+            
 ##         print >>fout, e[entry_type][entry]
         cont=1
         while cont:
@@ -160,7 +161,7 @@ def readTable(table):
             sp=l.split(':')
             kw=sp[0].strip()
             val=":".join(sp[1:]).split('!')[0].strip()
-##             print >>fout, 'dic is:',e[entry_type][entry]
+            ## print  'dic is:',e[entry_type][entry]
             if e[entry_type][entry].has_key(kw):
                 if kw in lists_kw:
                     e[entry_type][entry][kw]="".join(e[entry_type][entry][kw])
@@ -439,18 +440,23 @@ def checkCMOR(fout,file,table,noerror=cmor.CMOR_CRITICAL,variable=None,from_boun
 
 
         if major>=2: # more file structure there
-            tbl_id = getattr(file,'table_id').split()[1]
-            tbl_date= getattr(file,'table_id').split('(')[1].split(')')[0].strip()
-            ttbl_id = e['general'].get("table_id").split()[1]
-            ttbl_date = e['general'].get("table_date").strip()
+            try:
+                tmp_tbl_nm = getattr(file,'table_id')
+                tbl_id = tmp_tbl_nm.split()[1]
+                tbl_date= tmp_tbl_nm.split('(')[1].split(')')[0].strip()
+                ttbl_id = e['general'].get("table_id").split()[1]
+                ttbl_date = e['general'].get("table_date").strip()
+                if tbl_date!=ttbl_date:
+                    nwarn+=1
+                    ncheck+=1
+                    manageLog(fout,cmor.CMOR_WARNING,"File says table date was %s, but your table is dated from: %s" %( tbl_date,ttbl_date))
+
+                if tbl_id!=ttbl_id:
+                    nerr+=manageLog(fout, noerror, 'your file indicates a table id of %s while your table id is %s' % (tbl_id,ttbl_id))
+            except:
+                manageLog(fout,VERBOSE,"File says table is %s, this is not a correct name, correct format is something like: Table 3hr (24 May 2010) af8b1d3d63376942a55d779d0fb9f504" % (tmp_tbl_nm))
 
-            if tbl_date!=ttbl_date:
-                nwarn+=1
-                ncheck+=1
-                manageLog(fout,cmor.CMOR_WARNING,"File says table date was %s, but your table is dated from: %s" %( tbl_date,ttbl_date))
 
-            if tbl_id!=ttbl_id:
-                nerr+=manageLog(fout, noerror, 'your file indicates a table id of %s while your table id is %s' % (tbl_id,ttbl_id))
 
             sp = shrt_fnm.split(v)[1].split("_")
             t = file[v].getTime()
@@ -606,27 +612,21 @@ def checkCMOR(fout,file,table,noerror=cmor.CMOR_CRITICAL,variable=None,from_boun
                     d0=ft0.day
 
                 if interval < 86000:
-                    
-                    if len(dates[0])<10:
-                        nerr+=manageLog(fout, noerror, 'your file name indicates a start time with years, months and days only when the approximate interval says it should have hours')
+                    if len(dates[0])<12:
+                        nerr+=manageLog(fout, noerror, 'your file name indicates a start time with years, months, days and hours only when the approximate interval says it should have minutes')
                     try:
                         h0 = int(dates[0][8:10])
                     except:
                         nerr+=manageLog(fout, noerror, 'could not convert the hours section start date iun your file',dates[0][8:10])
-                else:
-                    h0= ft0.hour
-
-                if interval < 3000:
-                    if len(dates[0])<12:
-                        nerr+=manageLog(fout, noerror, 'your file name indicates a start time with years, months, days and hours only when the approximate interval says it should have minutes')
                     try:
                         mn0 = int(dates[0][10:12])
                     except:
                         nerr+=manageLog(fout, noerror, 'could not convert the miuntes section start date iun your file',dates[0][10:12])
-
                 else:
+                    h0= ft0.hour
                     mn0=ft0.minute
-                if interval < 50:
+
+                if interval < 3000:
                     if len(dates[0])<14:
                         nerr+=manageLog(fout, noerror, 'your file name indicates a start time with years, months, days, hours and minutes only when the approximate interval says it should have seconds')
                     try:
@@ -1128,7 +1128,7 @@ def checkCMOR(fout,file,table,noerror=cmor.CMOR_CRITICAL,variable=None,from_boun
                     nerr+=manageLog(fout, noerror, 'first longitude must be >= 0 degrees_east')
                 manageLog(fout,VERBOSE, '\t\tChecking that the longitude are in degrees (not rads)')
                 min,max=genutil.minmax(ax[:])
-                if max-min<6.3:
+                if 0.<max-min<6.3:
                     nerr+=manageLog(fout, noerror, 'longitude must be stored in degree span is:'+str(max-min)+' looks like rad')
             elif ax.isLatitude():
                 manageLog(fout,VERBOSE, '\t\tChecking for axis attribute')
@@ -1147,7 +1147,7 @@ def checkCMOR(fout,file,table,noerror=cmor.CMOR_CRITICAL,variable=None,from_boun
 ##                         manageLog(fout,cmor.CMOR_WARNING, '\t\t\tWe recomend latitude axis name to be: "lat"')
                 manageLog(fout,VERBOSE, '\t\tChecking that the latitude are in degrees (not rads)')
                 min,max=genutil.minmax(ax[:])
-                if max-min<3.2:
+                if 0.<max-min<3.2:
                     print ax[:]
                     nerr+=manageLog(fout, noerror, 'latitude must be stored in degree span is:'+str(max-min)+' looks like rad')
             elif ax.isTime() and len(ax[:])>1:
@@ -1500,7 +1500,7 @@ if __name__=='__main__':
     
     grid_table = None
     
-    noerror=True
+    noerror=cmor.CMOR_CRITICAL
     out='screen'
     
     help="""
@@ -1537,9 +1537,9 @@ if __name__=='__main__':
             sys.exit()
         if o in ['--noerror','-e']:
             if p.lower() in ['off','0']:
-                noerror=False
+                noerror=cmor.VERBOSE
             elif p.lower() in ['on','1']:
-                noerror=True
+                noerror=cmor.CMOR_CRITICAL
         if o in ['--out','-o']:
             out=p
 
@@ -1560,7 +1560,7 @@ if __name__=='__main__':
             fout=open(fout,'w')
         else:
             fout=open(out,'w')
-        if noerror:
+        if noerror==VERBOSE:
             checkCMOR(fout,file.strip(),table,other_tables=[grid_table,],noerror=noerror,variable=var)
         else:
             try:
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 9edb7c6..c95a591 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -1,3 +1,6 @@
+2010-05-28 : reverted file name construction to use first/last time. BUT added precision for daily and higher frequencies
+2010-05-28 : fixed a bug in cmor checker when variable entry was "pop" would break
+2010-05-28 : fixed default values of noerror in script from True to cmor.CMOR_CRITICAL
 2010-05-27 : switch version tagging from svn to git
 2010-05-27 : fixed  abug in test patch number of NetCDF3 version i was using = instead of ==
 2010-05-25 : trying a new way to store date in file names for Jamie. Probably going to be reverted
diff --git a/Src/cmor.c b/Src/cmor.c
index 7e6443f..82e98d1 100644
--- a/Src/cmor.c
+++ b/Src/cmor.c
@@ -490,8 +490,8 @@ void cmor_reset_variable(int var_id) {
   cmor_vars[var_id].values = NULL;
   cmor_vars[var_id].first_time=-999.;
   cmor_vars[var_id].last_time=-999.;
-  cmor_vars[var_id].first_bound=1.e20;
-  cmor_vars[var_id].last_bound=1.e20;
+  /* cmor_vars[var_id].first_bound=1.e20; */
+  /* cmor_vars[var_id].last_bound=1.e20; */
   cmor_vars[var_id].base_path[0]='\0';
   cmor_vars[var_id].current_path[0]='\0';
   cmor_vars[var_id].suffix[0]='\0';
@@ -3522,12 +3522,12 @@ int cmor_close_variable(int var_id, char *file_name, int *preserve)
       }
       
       /* ok makes a comptime out of input */
-      if (cmor_vars[var_id].first_bound!=1.e20) {
-	cdRel2Comp(icalo,msg,cmor_vars[var_id].first_bound,&comptime);
-      }
-      else {
+      /* if (cmor_vars[var_id].first_bound!=1.e20) { */
+      /* 	cdRel2Comp(icalo,msg,cmor_vars[var_id].first_bound,&comptime); */
+      /* } */
+      /* else { */
 	cdRel2Comp(icalo,msg,cmor_vars[var_id].first_time,&comptime);
-      }
+      /* } */
       /* need to figure out the approximate interval */
       interval  = cmor_convert_interval_to_seconds(cmor_tables[cmor_axes[cmor_vars[var_id].axes_ids[0]].ref_table_id].interval,cmor_tables[cmor_axes[cmor_vars[var_id].axes_ids[0]].ref_table_id].axes[cmor_axes[cmor_vars[var_id].axes_ids[0]].ref_axis_id].units);
       
@@ -3546,33 +3546,32 @@ int cmor_close_variable(int var_id, char *file_name, int *preserve)
 	strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
       }
       if (interval<86000) { /* less than a day */
+	/* from now on add 1 more level of precision since that frequency */
 	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)comptime.hour);
 	strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
-      }
-      if (interval<3000) { /* less than an hour */
-	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)comptime.hour*60);
+	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)((comptime.hour-(int)(comptime.hour))*60.));
 	strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
       }
-      if (interval<50) { /* less than an minute */
-	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)comptime.hour*3600);
+      if (interval<3000) { /* less than an hour */
+	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)((comptime.hour-(int)(comptime.hour))*3600.));
 	strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
       }
       
       
-      if (cmor_vars[var_id].last_bound!=1.e20) {
-	cdRel2Comp(icalo,msg,cmor_vars[var_id].last_bound,&comptime);
-      }
-      else {
+      /* if (cmor_vars[var_id].last_bound!=1.e20) { */
+      /* 	cdRel2Comp(icalo,msg,cmor_vars[var_id].last_bound,&comptime); */
+      /* } */
+      /* else { */
 	cdRel2Comp(icalo,msg,cmor_vars[var_id].last_time,&comptime);
-      }
+      /* } */
       
-      /* ok apparently we don't like the new time format if it's ending at midnight exactly so I'm removing one second...*/
-      if (icalo==cdMixed) {
-	cdCompAddMixed(comptime,-1./3600.,&comptime);
-      }
-      else{
-	cdCompAdd(comptime,-1./3600.,icalo,&comptime);
-      }
+      /* /\* ok apparently we don't like the new time format if it's ending at midnight exactly so I'm removing one second...*\/ */
+      /* if (icalo==cdMixed) { */
+      /* 	cdCompAddMixed(comptime,-1./3600.,&comptime); */
+      /* } */
+      /* else{ */
+      /* 	cdCompAdd(comptime,-1./3600.,icalo,&comptime); */
+      /* } */
       /* separator between first and last time */
       strncat(outname,"-",CMOR_MAX_STRING-strlen(outname));
       
@@ -3588,15 +3587,14 @@ int cmor_close_variable(int var_id, char *file_name, int *preserve)
 	strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
       }
       if (interval<86000) { /* less than a day */
+	/* from now on add 1 more level of precision since that frequency */
 	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)comptime.hour);
 	strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
-      }
-      if (interval<3000) { /* less than an hour */
-	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)comptime.hour*60);
+	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)((comptime.hour-(int)(comptime.hour))*60.));
 	strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
       }
-      if (interval<50) { /* less than an minute */
-	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)comptime.hour*3600);
+      if (interval<3000) { /* less than an hour */
+	snprintf(msg2,CMOR_MAX_STRING,"%.2i",(int)((comptime.hour-(int)(comptime.hour))*3600.));
 	strncat(outname,msg2,CMOR_MAX_STRING-strlen(outname));
       }
       
diff --git a/Src/cmor_variables.c b/Src/cmor_variables.c
index 188f4d2..65baef9 100644
--- a/Src/cmor_variables.c
+++ b/Src/cmor_variables.c
@@ -1479,12 +1479,12 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
 	ierr = cmor_check_values_inside_bounds(&time_vals[0],&time_bounds[0], ntimes_passed, "time");
 	ierr = nc_put_vara_double(ncid,avar->time_bnds_nc_id,starts,counts2,tmp_vals);
 	if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NetCDF error (%i) writing time bounds for variable '%s', already written in file: %i",ierr,avar->id,avar->ntimes_written);cmor_handle_error(msg,CMOR_CRITICAL);}
-	/* ok first time around the we need to store bounds */
-	if (avar->ntimes_written == 0) {
-	  /* ok first time we're putting data  in */
-	  avar->first_bound = tmp_vals[0];
-	}
-	avar->last_bound = tmp_vals[ntimes_passed*2-1];
+	/* /\* ok first time around the we need to store bounds *\/ */
+	/* if (avar->ntimes_written == 0) { */
+	/*   /\* ok first time we're putting data  in *\/ */
+	/*   avar->first_bound = tmp_vals[0]; */
+	/* } */
+	/* avar->last_bound = tmp_vals[ntimes_passed*2-1]; */
 	
 	
 	/* ok since we have bounds we need to set time in the middle */
@@ -1531,8 +1531,8 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
 	  snprintf(msg,CMOR_MAX_STRING,"in cmor_write, time axis must have bounds, please pass them to cmor_write along with time values");
 	  cmor_handle_error(msg,CMOR_CRITICAL);
 	}
-	avar->first_bound=1.e20;
-	avar->last_bound=1.e20;
+	/* avar->first_bound=1.e20; */
+	/* avar->last_bound=1.e20; */
 	cmor_get_axis_attribute(avar->axes_ids[0],"units",'c',&msg);
 	cmor_get_cur_dataset_attribute("calendar",msg2);
 	tmp_vals = malloc(ntimes_passed*sizeof(double));
@@ -1564,11 +1564,11 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
 	counts2[1]=2;
 	ierr = nc_put_vara_double(ncid,avar->time_bnds_nc_id,starts,counts2,&cmor_axes[avar->axes_ids[0]].bounds[starts[0]*2]);
 	if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NCError (%i) writting time bounds values for variable '%s'",ierr,avar->id);cmor_handle_error(msg,CMOR_CRITICAL);}
-	/* ok we need to store first and last bounds */
-	if (avar->ntimes_written==0) {
-	  avar->first_bound=cmor_axes[avar->axes_ids[0]].bounds[starts[0]*2];
-	}
-	avar->last_bound=cmor_axes[avar->axes_ids[0]].bounds[(starts[0]+counts[0])*2];
+	/* /\* ok we need to store first and last bounds *\/ */
+	/* if (avar->ntimes_written==0) { */
+	/*   avar->first_bound=cmor_axes[avar->axes_ids[0]].bounds[starts[0]*2]; */
+	/* } */
+	/* avar->last_bound=cmor_axes[avar->axes_ids[0]].bounds[(starts[0]+counts[0])*2]; */
       }
       else {
 	/* checks wether you need bounds or not */
@@ -1576,8 +1576,8 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
 	  snprintf(msg,CMOR_MAX_STRING,"in cmor_write, time axis must have bounds, you defined it w/o");
 	  cmor_handle_error(msg,CMOR_CRITICAL);
 	}
-	avar->first_bound=1.e20;
-	avar->last_bound=1.e20;
+	/* avar->first_bound=1.e20; */
+	/* avar->last_bound=1.e20; */
       }
       ierr = nc_put_vara_double(ncid,avar->time_nc_id,starts,counts,&cmor_axes[avar->axes_ids[0]].values[starts[0]]);
       if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NCError (%i) writting time values for variable '%s'",ierr,avar->id);cmor_handle_error(msg,CMOR_CRITICAL);}
@@ -1603,8 +1603,8 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
 	snprintf(msg,CMOR_MAX_STRING,"in cmor_write: variable '%s' you are passing %i times but no values and you did not define them via cmor_axis",avar->id,ntimes_passed);
 	cmor_handle_error(msg,CMOR_CRITICAL);
       }
-      avar->first_bound=1.e20;
-      avar->last_bound=1.e20;
+      /* avar->first_bound=1.e20; */
+      /* avar->last_bound=1.e20; */
       if (cmor_axes[avar->axes_ids[ierr]].bounds!=NULL) {
 	/* ok at that stage the recentering must already be done so we just need to write the bounds */
 	counts2[0]=counts[0];
@@ -1613,8 +1613,8 @@ int cmor_write_var_to_file(int ncid,cmor_var_t *avar,void *data,char itype, int
 	starts[1]=0;
 	ierr = nc_put_vara_double(ncid,avar->time_bnds_nc_id,starts,counts2,&cmor_axes[avar->axes_ids[0]].bounds[starts[0]*2]);
 	if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NCError (%i) writting time bounds values for variable '%s'",ierr,avar->id);cmor_handle_error(msg,CMOR_CRITICAL);}
-	avar->first_bound=cmor_axes[avar->axes_ids[0]].bounds[0];
-	avar->last_bound=cmor_axes[avar->axes_ids[0]].bounds[counts[0]*2];
+	/* avar->first_bound=cmor_axes[avar->axes_ids[0]].bounds[0]; */
+	/* avar->last_bound=cmor_axes[avar->axes_ids[0]].bounds[counts[0]*2]; */
       }
       ierr = nc_put_vara_double(ncid,avar->time_nc_id,starts,counts,&cmor_axes[avar->axes_ids[0]].values[starts[0]]);
       if (ierr != NC_NOERR) {snprintf(msg,CMOR_MAX_STRING,"NCError (%i) writting time values for variable '%s'",ierr,avar->id);cmor_handle_error(msg,CMOR_CRITICAL);}
diff --git a/include/cmor.h b/include/cmor.h
index 624b712..1b7dba0 100644
--- a/include/cmor.h
+++ b/include/cmor.h
@@ -216,8 +216,8 @@ typedef struct cmor_var_ {
   double *values;
   double first_time;
   double last_time;
-  double first_bound;
-  double last_bound;
+  /* double first_bound; */
+  /* double last_bound; */
   char base_path[CMOR_MAX_STRING];
   char current_path[CMOR_MAX_STRING];
   char suffix[CMOR_MAX_STRING];

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cmor.git



More information about the debian-science-commits mailing list