Changeset 4217 for exist/trunk


Ignore:
Timestamp:
22/09/08 17:31:19 (11 years ago)
Author:
cbyrom
Message:

Adjust atom to include atom type term ID as well as the vocab url - and
update the vocab data to include the terms for the various different
atom subtypes.

Location:
exist/trunk/python/ndgUtils
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/models/Atom.py

    r4214 r4217  
    127127        if atomType: 
    128128            logging.info(" - of type '%s'" %atomType) 
    129         self.atomType = atomType 
     129        self.atomTypeID = atomType 
    130130 
    131131        # some data have further subtypes specified 
     
    168168        else: 
    169169            self.VTD = VTD() 
    170           
     170 
     171        if self.atomTypeID: 
     172            self.atomTypeName = self.VTD.TERM_DATA[self.atomTypeID].title 
     173 
    171174        self.ME = ME.MolesEntity() 
    172175         
     
    187190 
    188191 
     192    def getValidSubTypes(self): 
     193        ''' 
     194        Get list of subtypes that are valid wrt this atom type 
     195        ''' 
     196        logging.debug("Lookup up subtypes for type, '%s'" %self.atomTypeID) 
     197        subTypes = self.VTD.SUBTYPE_TERMS.get(self.atomTypeID) or [] 
     198        logging.debug(subTypes) 
     199        return subTypes 
     200         
     201             
     202 
    189203    def __addAtomTypeDataXML(self, root): 
    190204        ''' 
     
    192206        - and lookup and add the appropriate vocab term data 
    193207        ''' 
    194         if self.atomType: 
     208        if self.atomTypeID: 
    195209            logging.info("Adding atom type info to XML output") 
    196210            category = Category() 
    197             category.label = self.VTD.TERM_DATA[self.atomType].title 
     211            category.label = self.atomTypeID 
    198212            # look up the appropriate vocab term data 
    199             category.scheme = self.VTD.getTermCurrentVocabURL(self.atomType) 
     213            category.scheme = self.VTD.getTermCurrentVocabURL(self.atomTypeID) 
    200214            category.term = self.ATOM_TYPE 
    201215            root.append(category.toXML()) 
     
    204218            logging.info("Adding atom subtype info to XML output") 
    205219            # NB subtypes not all defined, so leave this out for the moment 
    206             category.label = self.subtype #self.VTD.TERM_DATA[self.subtype].title 
     220            category.label = self.subtype 
    207221            # look up the appropriate vocab term data 
    208             category.scheme = 'NOT SET UP AT PRESENT'#self.VTD.getTermCurrentVocabURL(self.subtype) 
     222            category.scheme = self.VTD.getTermCurrentVocabURL(self.subtype) 
    209223            category.term = self.ATOM_SUBTYPE 
    210224            root.append(category.toXML()) 
     
    511525            if cat.term == self.ATOM_TYPE: 
    512526                logging.debug("Found atom type data") 
    513                 self.atomType = cat.label 
     527                self.atomTypeID = cat.label 
     528                self.atomTypeName = self.VTD.TERM_DATA[cat.label].title  
    514529                continue 
    515530            elif cat.term == self.ATOM_SUBTYPE: 
  • exist/trunk/python/ndgUtils/models/MolesEntity.py

    r4214 r4217  
    176176        deploymentLink = DeploymentLink(contentURL, vocabURL, title=title) 
    177177 
    178         logging.info(VTD.TERM_DATA[VTD.ACTIVITY_TERM].vocabURL) 
    179178        self._addDeploymentDetails(deploymentLink) 
    180179 
  • exist/trunk/python/ndgUtils/vocabtermdata.py

    r4209 r4217  
    4242    DE_TERM = "DE" 
    4343     
     44    LIDAR_TERM = "dgLidar" 
     45    RADAR_TERM = "dgRadar" 
     46    SONDE_TERM = "dgSonde" 
     47    NAVIGATION_TERM = "dgNavigation" 
     48    GAS_CHROMATOGRAPH_TERM = "dgGasChromatograph" 
     49    SPECTROMETER_TERM = "dgSpectrometer" 
     50    MASS_SPECTROMETER_TERM = "dgMassSpectrometer" 
     51     
     52    SIMULATION_TERM = "dgSimulation" 
     53    ANALYSIS_TERM = "dgAnalysis" 
     54    MEASUREMENT_TERM = "dgMeasurement" 
     55     
     56    DATA_COLLECTION_TERM = "dgDataCollection" 
     57    DATA_PROJECT_TERM = "dgDataProject" 
     58    DATA_CAMPAIGN_TERM = "dgDataCampaignProject" 
     59    DATA_INVESTIGATION_TERM = "dgDataInvestigation" 
     60    FLIGHT_TERM = "dgFlight" 
     61    CRUISE_TERM = "dgCruise" 
     62    FUNDING_PROGRAM_TERM = "dgFundingProgram" 
     63     
     64    STATIONARY_PLATFORM_TERM = "dgStationaryPlatform" 
     65    MOVING_PLATFORM_TERM = "dgMovingPlatform" 
     66    LAND_STATION_TERM = "dgLandStation" 
     67    MOORING_TERM = "dgMooring" 
     68    STATION_GROUP_TERM = "dgStationGroup" 
     69    SHIP_TERM = "dgShip" 
     70    AIRCRAFT_TERM = "dgAircraft" 
     71    SATELLITE_TERM = "dgSatellite" 
     72    COMPUTER_TERM = "dgComputer" 
     73 
    4474    TERM_DATA = { 
    4575                 URI_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/N041', '3', title = 'Data Home Page'), 
     
    5989                 OBS_TERM:VocabTermItem('OBS - NOT YET SET UP', 'OBS', title = 'Observation Station'), 
    6090                 GRANULE_TERM:VocabTermItem('GRAN - NOT YET SET UP', 'GRAN', title = 'Data Granule'), 
    61                  DE_TERM:VocabTermItem('DE - NOT YET SET UP', 'DE', title = 'Data Entity') 
     91                 DE_TERM:VocabTermItem('DE - NOT YET SET UP', 'DE', title = 'Data Entity'), 
     92                 LIDAR_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG02', title = LIDAR_TERM), 
     93                 RADAR_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG03', title = RADAR_TERM), 
     94                 SONDE_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG04', title = SONDE_TERM), 
     95                 NAVIGATION_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG05', title = NAVIGATION_TERM), 
     96                 GAS_CHROMATOGRAPH_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG06', title = GAS_CHROMATOGRAPH_TERM), 
     97                 SPECTROMETER_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG07', title = SPECTROMETER_TERM), 
     98                 MASS_SPECTROMETER_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG08', title = MASS_SPECTROMETER_TERM), 
     99                 SIMULATION_TERM:VocabTermItem('NOT YET SET UP', SIMULATION_TERM, title = SIMULATION_TERM), 
     100                 ANALYSIS_TERM:VocabTermItem('NOT YET SET UP', ANALYSIS_TERM, title = ANALYSIS_TERM), 
     101                 MEASUREMENT_TERM:VocabTermItem('NOT YET SET UP', MEASUREMENT_TERM, title = MEASUREMENT_TERM), 
     102                 DATA_COLLECTION_TERM:VocabTermItem('NOT YET SET UP', DATA_COLLECTION_TERM, title = DATA_COLLECTION_TERM), 
     103                 DATA_PROJECT_TERM:VocabTermItem('NOT YET SET UP', DATA_PROJECT_TERM, title = DATA_PROJECT_TERM), 
     104                 DATA_CAMPAIGN_TERM:VocabTermItem('NOT YET SET UP', DATA_CAMPAIGN_TERM, title = DATA_CAMPAIGN_TERM), 
     105                 DATA_INVESTIGATION_TERM:VocabTermItem('NOT YET SET UP', DATA_INVESTIGATION_TERM, title = DATA_INVESTIGATION_TERM), 
     106                 FLIGHT_TERM:VocabTermItem('NOT YET SET UP', FLIGHT_TERM, title = FLIGHT_TERM), 
     107                 CRUISE_TERM:VocabTermItem('NOT YET SET UP', CRUISE_TERM, title = CRUISE_TERM), 
     108                 FUNDING_PROGRAM_TERM:VocabTermItem('NOT YET SET UP', FUNDING_PROGRAM_TERM, title = FUNDING_PROGRAM_TERM), 
     109                  
     110                 STATIONARY_PLATFORM_TERM:VocabTermItem('NOT YET SET UP', STATIONARY_PLATFORM_TERM, title = STATIONARY_PLATFORM_TERM), 
     111                 MOVING_PLATFORM_TERM:VocabTermItem('NOT YET SET UP', MOVING_PLATFORM_TERM, title = MOVING_PLATFORM_TERM), 
     112                 LAND_STATION_TERM:VocabTermItem('NOT YET SET UP', LAND_STATION_TERM, title = LAND_STATION_TERM), 
     113                 MOORING_TERM:VocabTermItem('NOT YET SET UP', MOORING_TERM, title = MOORING_TERM), 
     114                 STATION_GROUP_TERM:VocabTermItem('NOT YET SET UP', STATION_GROUP_TERM, title = STATION_GROUP_TERM), 
     115                 SHIP_TERM:VocabTermItem('NOT YET SET UP', SHIP_TERM, title = SHIP_TERM), 
     116                 AIRCRAFT_TERM:VocabTermItem('NOT YET SET UP', AIRCRAFT_TERM, title = AIRCRAFT_TERM), 
     117                 SATELLITE_TERM:VocabTermItem('NOT YET SET UP', SATELLITE_TERM, title = SATELLITE_TERM), 
     118                 COMPUTER_TERM:VocabTermItem('NOT YET SET UP', COMPUTER_TERM, title = COMPUTER_TERM), 
     119                  
     120                 #_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG09', title = _TERM), 
     121                 #_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG10', title = _TERM), 
     122                 #_TERM:VocabTermItem('http://vocab.ndg.nerc.ac.uk/term/C330', 'NG1', title = _TERM), 
    62123                 } 
     124 
     125     
     126             #'dgMetSensor':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG09', 
     127             #'dgDOAS':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG10', 
     128             #'dgASOZ':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG11', 
     129             #'dgRadiometer':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG12', 
     130             #'dgFAGE':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG13', 
     131             #'dgImager':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG14', 
     132             #'dgFilter':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG15', 
     133             #'dgParticleCounter':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG16', 
     134             #'dgSampler':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG17', 
     135             #'dgOtherInstrumentType':'http://vocab.ndg.nerc.ac.uk/term/C330/0/NG99', 
     136             #'dgModel':'dgModel - NOT YET SET UP', 
     137             #'dgInstrument':'dgInstrument - NOT YET SET UP' 
     138 
     139 
     140     
     141    # A dictionary to group the various valid subtypes of atoms - grouped by their 
     142    # main type 
     143    SUBTYPE_TERMS = { 
     144                     DPT_TERM: [ 
     145                        TERM_DATA[LIDAR_TERM], TERM_DATA[RADAR_TERM], \ 
     146                        TERM_DATA[SONDE_TERM], TERM_DATA[NAVIGATION_TERM], \ 
     147                        TERM_DATA[GAS_CHROMATOGRAPH_TERM], TERM_DATA[SPECTROMETER_TERM], \ 
     148                        TERM_DATA[MASS_SPECTROMETER_TERM] 
     149                        ], 
     150 
     151                     DE_TERM: [ 
     152                        TERM_DATA[SIMULATION_TERM], TERM_DATA[ANALYSIS_TERM], \ 
     153                        TERM_DATA[MEASUREMENT_TERM]        
     154                        ], 
     155                     ACTIVITY_TERM: [ 
     156                        TERM_DATA[DATA_COLLECTION_TERM], TERM_DATA[DATA_PROJECT_TERM], \ 
     157                        TERM_DATA[DATA_CAMPAIGN_TERM], TERM_DATA[DATA_INVESTIGATION_TERM], \ 
     158                        TERM_DATA[FLIGHT_TERM], TERM_DATA[CRUISE_TERM], \ 
     159                        TERM_DATA[FUNDING_PROGRAM_TERM], 
     160                        ], 
     161                     OBS_TERM: [ 
     162                        TERM_DATA[STATIONARY_PLATFORM_TERM], TERM_DATA[MOVING_PLATFORM_TERM], \ 
     163                        TERM_DATA[LAND_STATION_TERM], TERM_DATA[MOORING_TERM], \ 
     164                        TERM_DATA[STATION_GROUP_TERM], TERM_DATA[SHIP_TERM], \ 
     165                        TERM_DATA[AIRCRAFT_TERM], TERM_DATA[SATELLITE_TERM], \ 
     166                        TERM_DATA[COMPUTER_TERM]  
     167                        ] 
     168                     } 
     169              
     170 
     171 
     172     
    63173     
    64174    ONE_HOUR = 3600.0 
     
    75185        logging.info("VocabTermData object set up") 
    76186 
     187 
     188    def getTermFromTitle(self, title): 
     189        ''' 
     190        Given a term title/label, get back the related term id 
     191        @param title: title/label of term id to retrieve 
     192        @raise ValueError: if more than one title or no title is returned   
     193        ''' 
     194        termID = [] 
     195        for val in self.TERM_DATA.itervalues(): 
     196            if val.title == title: 
     197                termID.append(val.termID) 
     198         
     199        if len(termID) != 1: 
     200            errorMessage = "Error: could not accurately determine the vocab term \ 
     201                ID for the label, '%s' - %s values returned" %(title, len(termID)) 
     202            logging.error(errorMessage) 
     203            raise ValueError(errorMessage) 
     204 
     205        return termID[0] 
     206         
    77207 
    78208    def _getVocabDataPage(self): 
Note: See TracChangeset for help on using the changeset viewer.