nappy/contrib/aircraft/old_na_to_nc_with_aircraft.py
def defineNAGlobals(self):
        """
	Maps CDMS (NetCDF) global attributes into NASA Ames Header fields.
	"""
	# Get the global mapping dictionary
        globalmap=cdmsMap.toNA
	# Check if we should add to it with locally set rules
	locGlobs=localRules.localGlobalAttributes
        for att in locGlobs.keys():
	    if not globalmap.has_key(att):
	        globalmap[key]=locGlobs[key]

        self.extra_comments=[[],[],[]]  # Normal comments, special comments, other comments
	conventionOrReferenceComments=[]
        for key in self.globals.keys():
            if key!="first_valid_date_of_data" and type(self.globals[key]) not in (str, float, int): continue
            if key in globalmap.keys():
                if key=="history":
                    timestring=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
                    history="History:\t%s - Converted to NASA Ames format using nappy-%s.\n\t%s" % (timestring, version.version, self.globals[key])
                    history=history.split("\n") 
                    self.history=[]
                    for h in history:
                        if h[:8]!="History:" and h[:1]!="\t": h="\t"+h
                        self.history.append(h) 
                    
                elif key=="institution":
		    # If fields came from NA then extract appropriate fields.
		    match=re.match(r"(.*)\s+\(ONAME from NASA Ames file\);\s+(.*)\s+\(ORG from NASA Ames file\)\.", self.globals[key])
		    if match:
		        self.na_dict["ONAME"]=match.groups()[0]
			self.na_dict["ORG"]=match.groups()[1]
		    else:
                        self.na_dict["ONAME"]=self.globals[key]
                        self.na_dict["ORG"]=self.globals[key]		    
		    
		    # NOte: should probably do the following search and replace on all string lines
		    self.na_dict["ONAME"]=self.na_dict["ONAME"].replace("\n", "  ")
		    self.na_dict["ORG"]=self.na_dict["ORG"].replace("\n", "  ")
		    		    
                elif key=="comment":
		    # Need to work out if they are actually comments from NASA Ames in the first place
                    #self.ncom=[self.globals[key]]
		    comLines=self.globals[key].split("\n")
		    normComms=[]
		    normCommFlag=None
		    specComms=[]
		    specCommFlag=None
		    for line in comLines:
		        if line.find("###NASA Ames Special Comments follow###")>-1:
			    specCommFlag=1
			elif line.find("###NASA Ames Special Comments end###")>-1:
			    specCommFlag=None
		        elif line.find("###NASA Ames Normal Comments follow###")>-1:
			    normCommFlag=1
			elif line.find("###NASA Ames Normal Comments end###")>-1:
			    normCommFlag=None	
			elif specCommFlag==1:
			    specComms.append(line)
			elif normCommFlag==1:
			    normComms.append(line)
			elif line.find("###Data Section begins on the next line###")>-1:
			    pass
			else:
			    normComms.append(line)	    
		    
		    self.extra_comments=[specComms, normComms, []]		    
		   		    
		elif key=="first_valid_date_of_data":
		    self.na_dict["DATE"]=self.globals[key]
		
                elif key in ("Conventions", "references"):
                    #conventionOrReferenceComments.append("%s:   %s" % (key, self.globals[key]))
		    self.extra_comments[2].append("%s:   %s" % (key, self.globals[key]))
                else:
                    self.na_dict[globalmap[key]]=self.globals[key]
            else:
                self.extra_comments[2].append("%s:   %s" % (key, self.globals[key]))
	#self.extra_comments
        return

	Maps CDMS (NetCDF) global attributes into NASA Ames Header fields.
	
Maps CDMS (NetCDF) global attributes into NASA Ames Header fields.
Maps CDMS ( NetCDF ) global attributes into NASA Ames Header fields .
def defineNAGlobals(self):
        globalmap=cdmsMap.toNA
	locGlobs=localRules.localGlobalAttributes
        for att in locGlobs.keys():
	    if not globalmap.has_key(att):
	        globalmap[key]=locGlobs[key]
        self.extra_comments=[[],[],[]]  
	conventionOrReferenceComments=[]
        for key in self.globals.keys():
            if key!="first_valid_date_of_data" and type(self.globals[key]) not in (str, float, int): continue
            if key in globalmap.keys():
                if key=="history":
                    timestring=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
                    history="History:\t%s - Converted to NASA Ames format using nappy-%s.\n\t%s" % (timestring, version.version, self.globals[key])
                    history=history.split("\n") 
                    self.history=[]
                    for h in history:
                        if h[:8]!="History:" and h[:1]!="\t": h="\t"+h
                        self.history.append(h) 
                elif key=="institution":
		    match=re.match(r"(.*)\s+\(ONAME from NASA Ames file\);\s+(.*)\s+\(ORG from NASA Ames file\)\.", self.globals[key])
		    if match:
		        self.na_dict["ONAME"]=match.groups()[0]
			self.na_dict["ORG"]=match.groups()[1]
		    else:
                        self.na_dict["ONAME"]=self.globals[key]
                        self.na_dict["ORG"]=self.globals[key]		    
		    self.na_dict["ONAME"]=self.na_dict["ONAME"].replace("\n", "  ")
		    self.na_dict["ORG"]=self.na_dict["ORG"].replace("\n", "  ")
                elif key=="comment":
		    comLines=self.globals[key].split("\n")
		    normComms=[]
		    normCommFlag=None
		    specComms=[]
		    specCommFlag=None
		    for line in comLines:
		        if line.find("###NASA Ames Special Comments follow###")>-1:
			    specCommFlag=1
			elif line.find("###NASA Ames Special Comments end###")>-1:
			    specCommFlag=None
		        elif line.find("###NASA Ames Normal Comments follow###")>-1:
			    normCommFlag=1
			elif line.find("###NASA Ames Normal Comments end###")>-1:
			    normCommFlag=None	
			elif specCommFlag==1:
			    specComms.append(line)
			elif normCommFlag==1:
			    normComms.append(line)
			elif line.find("###Data Section begins on the next line###")>-1:
			    pass
			else:
			    normComms.append(line)	    
		    self.extra_comments=[specComms, normComms, []]		    
		elif key=="first_valid_date_of_data":
		    self.na_dict["DATE"]=self.globals[key]
                elif key in ("Conventions", "references"):
		    self.extra_comments[2].append("%s:   %s" % (key, self.globals[key]))
                else:
                    self.na_dict[globalmap[key]]=self.globals[key]
            else:
                self.extra_comments[2].append("%s:   %s" % (key, self.globals[key]))
        return
def defineNAGlobals ( self ) : globalmap = cdmsMap . toNA locGlobs = localRules . localGlobalAttributes for att in locGlobs . keys ( ) : if not globalmap . has_key ( att ) : globalmap [ key ] = locGlobs [ key ] self . extra_comments = [ [ ] , [ ] , [ ] ] conventionOrReferenceComments = [ ] for key in self . globals . keys ( ) : if key != "first_valid_date_of_data" and type ( self . globals [ key ] ) not in ( str , float , int ) : continue if key in globalmap . keys ( ) : if key == "history" : timestring = time . strftime ( "%Y-%m-%d %H:%M:%S" , time . localtime ( time . time ( ) ) ) history = "History:\t%s - Converted to NASA Ames format using nappy-%s.\n\t%s" % ( timestring , version . version , self . globals [ key ] ) history = history . split ( "\n" ) self . history = [ ] for h in history : if h [ : 8 ] != "History:" and h [ : 1 ] != "\t" : h = "\t" + h self . history . append ( h ) elif key == "institution" : match = re . match ( r"(.*)\s+\(ONAME from NASA Ames file\);\s+(.*)\s+\(ORG from NASA Ames file\)\." , self . globals [ key ] ) if match : self . na_dict [ "ONAME" ] = match . groups ( ) [ 0 ] self . na_dict [ "ORG" ] = match . groups ( ) [ 1 ] else : self . na_dict [ "ONAME" ] = self . globals [ key ] self . na_dict [ "ORG" ] = self . globals [ key ] self . na_dict [ "ONAME" ] = self . na_dict [ "ONAME" ] . replace ( "\n" , "  " ) self . na_dict [ "ORG" ] = self . na_dict [ "ORG" ] . replace ( "\n" , "  " ) elif key == "comment" : comLines = self . globals [ key ] . split ( "\n" ) normComms = [ ] normCommFlag = None specComms = [ ] specCommFlag = None for line in comLines : if line . find ( "###NASA Ames Special Comments follow###" ) > - 1 : specCommFlag = 1 elif line . find ( "###NASA Ames Special Comments end###" ) > - 1 : specCommFlag = None elif line . find ( "###NASA Ames Normal Comments follow###" ) > - 1 : normCommFlag = 1 elif line . find ( "###NASA Ames Normal Comments end###" ) > - 1 : normCommFlag = None elif specCommFlag == 1 : specComms . append ( line ) elif normCommFlag == 1 : normComms . append ( line ) elif line . find ( "###Data Section begins on the next line###" ) > - 1 : pass else : normComms . append ( line ) self . extra_comments = [ specComms , normComms , [ ] ] elif key == "first_valid_date_of_data" : self . na_dict [ "DATE" ] = self . globals [ key ] elif key in ( "Conventions" , "references" ) : self . extra_comments [ 2 ] . append ( "%s:   %s" % ( key , self . globals [ key ] ) ) else : self . na_dict [ globalmap [ key ] ] = self . globals [ key ] else : self . extra_comments [ 2 ] . append ( "%s:   %s" % ( key , self . globals [ key ] ) ) return
Maps CDMS (NetCDF) global attributes into NASA Ames Header fields.
Maps CDMS ( NetCDF ) global attributes into NASA Ames Header fields .
"""
	Maps CDMS (NetCDF) global attributes into NASA Ames Header fields.
	""" # Get the global mapping dictionary
 # Check if we should add to it with locally set rules
 # Normal comments, special comments, other comments
 # If fields came from NA then extract appropriate fields.
 # NOte: should probably do the following search and replace on all string lines
 # Need to work out if they are actually comments from NASA Ames in the first place
 #self.ncom=[self.globals[key]]
 #conventionOrReferenceComments.append("%s:   %s" % (key, self.globals[key]))
 #self.extra_comments

self