Changeset 4699
- Timestamp:
- 22/12/08 22:37:11 (12 years ago)
- Location:
- nappy/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
nappy/trunk/nappy.ini
r4693 r4699 4 4 default_delimiter = __space____space____space____space__ 5 5 default_float_format = %g 6 comment_override_rule = extend6 comment_override_rule = insert 7 7 add_column_headers = True 8 8 annotations_file = annotations.ini … … 10 10 11 11 [header_partitions] 12 sc_start = "=== Special Comments follow==="13 sc_end = "=== Special Comments end==="14 nc_start = "=== Normal Comments follow==="15 nc_end = "=== Normal Comments end==="12 sc_start = "==== Special Comments follow ====" 13 sc_end = "==== Special Comments end ====" 14 nc_start = "==== Normal Comments follow ====" 15 nc_end = "==== Normal Comments end ====" 16 16 data_next = "=== Data Section begins on the next line ===" 17 sing_start = "== = Singleton Variables defined in the source file follow ==="18 sing_end = "== = Singleton Variables defined in the source file end ==="19 ncatts_start = "== = Variable attributes from source (NetCDF) file follow ==="20 ncatts_end = "== = Variable attributes from source (NetCDF) file end ==="21 addl_globals = " Additional Global Attributes defined in the source file and not translated elsewhere:"22 addl_vatts = " Additional Variable Attributes defined in the source file and not translated elsewhere:"17 sing_start = "== Singleton Variables defined in the source file follow ==" 18 sing_end = "== Singleton Variables defined in the source file end ==" 19 ncatts_start = "== Variable attributes from source (NetCDF) file follow ==" 20 ncatts_end = "== Variable attributes from source (NetCDF) file end ==" 21 addl_globals = "=== Additional Global Attributes defined in the source file ===" 22 addl_vatts = "=== Additional Variable Attributes defined in the source file ===" 23 23 24 24 [na_to_nc_map] -
nappy/trunk/nappy/nc_interface/na_content_collector.py
r4698 r4699 731 731 print msg 732 732 self.output_message.append(msg) 733 self.na_dict["DATE"] = [ -999] * 3733 self.na_dict["DATE"] = [999] * 3 734 734 else: 735 735 if not self.na_dict.has_key("DATE"): … … 737 737 print msg 738 738 self.output_message.append(msg) 739 self.na_dict["DATE"] = [ -999] * 3739 self.na_dict["DATE"] = [999] * 3 740 740 else: 741 741 pass # i.e. use existing DATE -
nappy/trunk/nappy/nc_interface/nc_to_na.py
r4693 r4699 44 44 add_column_headers = bool(nappy.utils.getDefault("add_column_headers")) 45 45 46 config_dict = nappy.utils.getConfigDict() 47 header_partitions = config_dict["header_partitions"] 48 hp = header_partitions 49 46 50 # Define global variables 47 51 permitted_overwrite_metadata = ("DATE", "RDATE", "ANAME", "MNAME", … … 188 192 if comment_override_rule == "replace": 189 193 comments_list = new_item[:] 190 elif comment_override_rule == "insert": 191 comments_list = new_item[:] + this_na_dict.get(key, []) 194 elif comment_override_rule in ("insert", "extend"): 195 comments_list = self._cleanWrapComments(existing_comments, new_comments, key, comment_override_rule) 196 else: 197 raise Exception("Did not recognise comment_override_rule: " + str(comment_override_rule)) 198 199 """elif comment_override_rule == "insert": 200 new_comments = new_items[:] 201 existing_comments = this_na_dict.get(key, []) 202 comments_list = self._cleanWrapComments(existing_comments, new_comments, key, comment_override_rule) 203 #comments_list = new_item[:] + this_na_dict.get(key, []) 192 204 elif comment_override_rule == "extend": 193 comments_list = this_na_dict.get(key, []) + new_item[:] 205 comments_list = this_na_dict.get(key, []) + new_item[:] """ 194 206 195 207 this_na_dict[key] = comments_list … … 225 237 226 238 # Report on what has been written 227 msg = "\nWrote the following variables:" + "\n \t" + ("\n\t".join(vars_to_write[0]))239 msg = "\nWrote the following variables:" + "\n " + ("\n ".join(vars_to_write[0])) 228 240 if DEBUG: print msg 229 241 self.output_message.append(msg) … … 232 244 aux_var_count = vars_to_write[1] 233 245 if len(aux_var_count) > 0: 234 msg = "\nWrote the following auxiliary variables:" + "\n \t" + ("\n\t".join(aux_var_count))246 msg = "\nWrote the following auxiliary variables:" + "\n " + ("\n ".join(aux_var_count)) 235 247 236 248 singleton_var_count = vars_to_write[2] 237 249 if len(singleton_var_count) > 0: 238 msg = "\nWrote the following Singleton variables:" + "\n \t" + ("\n\t".join(singleton_var_count))250 msg = "\nWrote the following Singleton variables:" + "\n " + ("\n ".join(singleton_var_count)) 239 251 240 252 if len(file_list) > 0: … … 348 360 na_dict["NNCOML"] = len(na_dict["NCOM"]) 349 361 return 362 363 364 def _cleanWrapComments(self, existing_comments, new_comments, key, comment_override_rule): 365 """ 366 Combines new_comments with existing_comments where comments are 367 either Special or Normal. 'key' defines this being defined as either 368 "SCOM" or "NCOM". 'comment_override_rule' is either "insert" (new_comments first) 369 or "extend" (existing_comments first). 370 Returns a new list of combined_comments. 371 """ 372 # Strip start header if used 373 c1 = key[0].lower() 374 start_line = hp[c1 + "c_start"] 375 start_used = False 376 377 if existing_comments[0] == start_line: 378 existing_comments = existing_comments[1:] 379 start_used = start_line 380 381 # Now check last line 382 end_line = hp[c1 + "c_end"] 383 end_used = False 384 385 if existing_comments[-1] == end_line: 386 existing_comments = existing_comments[:-1] 387 end_used = end_line 388 389 # Check for alternative last line in NCOM 390 if end_used == False and key == "NCOM": 391 end_line2 = hp["data_next"] 392 if existing_comments[-1] == end_line2: 393 existing_comments = existing_comments[:-1] 394 end_used = end_line2 395 396 # Now put back together 397 ordered_comments = [existing_comments, new_comments] 398 if comment_override_rule == "insert": 399 ordered_comments.reverse() 400 401 combined_comments = ordered_comments[0] + ordered_comments[1] 402 if start_used: 403 combined_comments.insert(0, start_used) 404 if end_used: 405 combined_comments.append(end_used) 406 407 return combined_comments 408
Note: See TracChangeset
for help on using the changeset viewer.