def setUp(self): ''' Setup of the test environment with a list of parser objects. Purpose of having a list of parsers doing the job in the setUp function is to simulate similar tasks during database import jobs (first parsing all available data files and following insert into the database. ''' # Getting the test glaciers. corbassiere = Glacier(None, 38, "B83/03", "Corbassière") findelen = Glacier(None, 16, "B56/03", "Findelen") self._glaciers[corbassiere.pkSgi] = corbassiere self._glaciers[findelen.pkSgi] = findelen # Setup of the input files. self._vawDataFiles.append("./VawDataFiles/corbassiere_glev.dat") self._vawDataFiles.append("./VawDataFiles/findelen_glev.dat") self._vawDataFiles.append("./VawDataFiles/gietro_glev.dat") self._vawDataFiles.append("./VawDataFiles/gorner_glev.dat") # Setup of class-wide parser objects. self._volumeChangeParsers = [] self._volumeChangeParsers.append( VolumeChangeReader(self._vawDataFiles[0], self._glaciers)) # Corbassière self._volumeChangeParsers.append( VolumeChangeReader(self._vawDataFiles[1], self._glaciers)) # Findelen # Running the parsing processes. for volumeChangeParser in self._volumeChangeParsers: volumeChangeParser.parse()
def setUp(self): ''' Setup of the test environment with a list of parser objects. Purpose of having a list of parsers doing the job in the setUp function is to simulate similar tasks during database import jobs (first parsing all available data files and following insert into the database. ''' # Getting the test glaciers. clariden = Glacier(None, 141, "A50i/19", "Clariden") adler = Glacier(None, 16, "B56/03", "Adler") self._glaciers[clariden.pkSgi] = clariden self._glaciers[adler.pkSgi] = adler # Reading the configuration file. self._configuration.read("../dataflow.cfg") # Setup of the input files. self._vawDataFiles.append("./VawDataFiles/adler_fix.dat") self._vawDataFiles.append("./VawDataFiles/adler_obs.dat") self._vawDataFiles.append("./VawDataFiles/clariden_fix.dat") self._vawDataFiles.append("./VawDataFiles/clariden_obs.dat") # Setup of class-wide parser objects. self._massBalanceParsers = [] self._massBalanceParsers.append( MassBalanceReader(self._configuration, self._vawDataFiles[3], self._glaciers)) # Clariden observations self._massBalanceParsers.append( MassBalanceReader(self._configuration, self._vawDataFiles[0], self._glaciers)) # Adler fix date readings # Running the parsing processes. for massBalanceParser in self._massBalanceParsers: massBalanceParser.parse()
def _recordToObject(self, dbRecord): ''' Converts a single record of the database into a glacier object. @type dbRecord: list @param dbRecord: List with all values of one database record. @rtype: Glacier @return: Glacier object of the database record. ''' pk = uuid.UUID(dbRecord[1]) if dbRecord[2] != None: pkVaw = int(dbRecord[2]) else: pkVaw = None pkSgi = dbRecord[5] name = dbRecord[6] return Glacier(pk, pkVaw, pkSgi, name)
# Check if the database is available. If not, get alternative glaciers for plotting. if glacierReader.isDatabaseAvailable == True: print( "The GLAMOS database is available. Glacier objects are read from the database." ) for focusGlacier in focusGlaciers: glacier = glacierReader.getGlacierBySgi(focusGlacier) glaciers[glacier.pkSgi] = glacier else: print( "The GLAMOS database is not available. Glacier objects are improvised." ) # Getting some improvised glaciers. clariden = Glacier(None, 141, "A50i/19", "Clariden") adler = Glacier(None, 16, "B56/03", "Adler") rhone = Glacier(None, 1, "B43/03", "Rhone") aletsch = Glacier(None, 5, "B36/26", "Aletsch") glaciers[clariden.pkSgi] = clariden glaciers[adler.pkSgi] = adler glaciers[rhone.pkSgi] = rhone glaciers[aletsch.pkSgi] = aletsch parseMassBalance(config, glaciers) for glacier in glaciers.values(): plotMassBalance(glacier) except Exception as e: