Changeset 4698
- Timestamp:
- 22/12/08 21:14:51 (12 years ago)
- Location:
- nappy/trunk/nappy
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
nappy/trunk/nappy/cdms_utils/axis_utils.py
r4693 r4698 40 40 41 41 # Check units 42 print ax1.id, ax2.id 43 if hasattr(ax1, "units"): 42 if hasattr(ax1, "units") and hasattr(ax2, "units"): 44 43 if ax1.units != ax2.units: return False 45 44 -
nappy/trunk/nappy/nc_interface/cdms_to_na.py
r4693 r4698 78 78 """ 79 79 if self.converted == True: 80 print "Already converted to NA dictionary objects."81 80 return self.na_dict_list 82 81 -
nappy/trunk/nappy/nc_interface/na_content_collector.py
r4693 r4698 76 76 # [ordered_vars, auxiliary_vars, rank_zero_vars] 77 77 self.var_ids = None 78 self.globals = dict(global_attributes) 78 self.globals = dict(global_attributes) 79 79 self.requested_ffi = requested_ffi 80 80 … … 140 140 self.rank_zero_var_ids.append(var.id) 141 141 continue 142 142 143 143 # Update highest if highest found or if equals highest with bigger size 144 144 try: … … 223 223 # OK, I think the current variable is compatible to write with the best variable along with a NASA Ames file 224 224 vars_for_na.append(var) 225 225 226 226 # Send vars_for_na AND aux_vars_for_na to a method to check if they have previously been mapped 227 227 # from NASA Ames. In which case we'll write them back in the order they were initially read from the input file. … … 274 274 aux_vars_for_na.append(var) 275 275 276 aux_vars_for_na = aux_vars_for_na + other_aux_vars 276 aux_vars_for_na = aux_vars_for_na + other_aux_vars 277 277 return (vars_for_na, aux_vars_for_na) 278 278 … … 508 508 if key == "history": 509 509 time_string = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) 510 history = "History: \t%s - Converted to NASA Ames format using nappy-%s.\n\t%s" % \510 history = "History: %s - Converted to NASA Ames format using nappy-%s.\n %s" % \ 511 511 (time_string, version, self.globals[key]) 512 512 history = history.split("\n") 513 513 self.history = [] 514 514 for h in history: 515 if h[:8] != "History:" and h[:1] != " \t":516 h = " \t" + h515 if h[:8] != "History:" and h[:1] != " ": 516 h = " " + h 517 517 self.history.append(h) 518 518 … … 526 526 else: 527 527 self.na_dict["ONAME"] = self.globals[key] 528 self.na_dict["ORG"] = self.globals[key] 528 self.na_dict["ORG"] = self.globals[key] 529 529 # NOTE: should probably do the following search and replace on all string lines 530 530 self.na_dict["ONAME"] = self.na_dict["ONAME"].replace("\n", " ") 531 531 self.na_dict["ORG"] = self.na_dict["ORG"].replace("\n", " ") 532 532 533 533 elif key == "comment": 534 534 # Need to work out if they are actually comments from NASA Ames in the first place … … 547 547 normal_comm_flag = 1 548 548 elif line.find(hp["nc_end"]) > -1: 549 normal_comm_flag = None 549 normal_comm_flag = None 550 550 elif special_comm_flag == 1: 551 551 special_comments.append(line) … … 555 555 pass 556 556 else: 557 normal_comments.append(line) 558 559 self.extra_comments = [special_comments, normal_comments, []] 560 557 normal_comments.append(line) 558 559 self.extra_comments = [special_comments, normal_comments, []] 560 561 561 elif key == "first_valid_date_of_data": 562 562 self.na_dict["DATE"] = self.globals[key] 563 563 564 564 elif key in ("Conventions", "references"): 565 565 #convention_or_reference_comments.append("%s: %s" % (key, self.globals[key])) … … 587 587 if len(NCOM) > 0: NCOM.append("") 588 588 589 # Use third item in self.extra_comments and adds to NCOM 589 # Use third item in self.extra_comments and adds to NCOM 590 590 if len(self.extra_comments[2]) > 0: 591 591 for excom in self.extra_comments[2]: 592 592 NCOM.append(excom) 593 593 594 594 if len(self.extra_comments[1]) > 0: 595 595 NCOM.append(hp["addl_globals"]) … … 630 630 631 631 for var in self.rank_zero_vars: 632 rank_zero_vars_string.append(" \tVariable %s: %s" % (var.id, nappy.cdms_utils.var_utils.getBestName(var)))632 rank_zero_vars_string.append(" Variable %s: %s" % (var.id, nappy.cdms_utils.var_utils.getBestName(var))) 633 633 634 634 for att in var.attributes.keys(): … … 637 637 if type(value) in (type("s"), type(1.0), type(1)): 638 638 639 rank_zero_vars_string.append(" \t\t%s = %s" % (att, var.attributes[att]))639 rank_zero_vars_string.append(" %s = %s" % (att, var.attributes[att])) 640 640 641 641 if len(rank_zero_vars_string) > 0: … … 659 659 660 660 if spec_comm_flag == None: 661 661 SCOM = [hp["sc_start"]] + rank_zero_vars_string 662 662 SCOM.append(hp["addl_vatts"]) 663 663 SCOM.append(hp["ncatts_start"]) … … 666 666 667 667 if var_name_written == False: 668 SCOM.append(" \tVariable %s: %s" % (var.id, name))668 SCOM.append(" Variable %s: %s" % (var.id, name)) 669 669 var_name_written = True 670 670 671 SCOM.append(" \t\t%s = %s" % (scom, value))671 SCOM.append(" %s = %s" % (scom, value)) 672 672 673 673 if var_comm_flag == 1: … … 686 686 for line in lines: 687 687 if line != lines[0]: 688 line = " \t" + line688 line = " " + line 689 689 690 690 NCOM_cleaned.append(line) 691 691 692 692 for c in SCOM: 693 if c.strip() not in ("", " ", " "): 693 if c.strip() not in ("", " ", " "): 694 694 # Replace new lines within one attribute with a newline and tab so easier to read 695 695 lines = c.split("\n") 696 696 for line in lines: 697 697 if line != lines[0]: 698 line = " \t" + line698 line = " " + line 699 699 700 700 SCOM_cleaned.append(line) … … 719 719 if not self.na_dict.has_key("RDATE"): 720 720 self.na_dict["RDATE"] = time_now 721 721 722 722 if self.ax0.isTime(): 723 723 # Get first date in list
Note: See TracChangeset
for help on using the changeset viewer.