Beispiel #1
0
 def global_translator(record):
     # field_names = id,latitude,longitude,elevation,location_name
     try:
         return Station(record['id'],
                        utils.ensure_precision(record['location']['point']['coordinates'][1],
                                               precisions[1]),
                        utils.ensure_precision(record['location']['point']['coordinates'][0],
                                               precisions[2]),
                        utils.ensure_precision(record['location']['point']['coordinates'][2],
                                               precisions[3]),
                        record['location']['locality'])
     except:
         return Station(record['id'],
                        utils.ensure_precision(record['location']['point']['coordinates'][1],
                                               precisions[1]),
                        utils.ensure_precision(record['location']['point']['coordinates'][0],
                                               precisions[2]),
                        '',
                        record['location']['locality'])
Beispiel #2
0
 def ushcn_translator(record):
     # field_names = id,latitude,longitude,elevation,state,locality,composite1,composite2,composite3,composite4,time_zone
     blank_composite = ['-----------']
     num_composites = 4
     if record['id'].startswith('USH'):
         if not isinstance(record['composites'], list):
             record['composites'] = num_composites * blank_composite
         else:
             record['composites'] += (num_composites - len(record['composites'])) * blank_composite
         try:
             return Station(record['id'],
                            utils.ensure_precision(record['location']['point']['coordinates'][1],
                                                   precisions[1]),
                            utils.ensure_precision(record['location']['point']['coordinates'][0],
                                                   precisions[2]),
                            utils.ensure_precision(record['location']['point']['coordinates'][2],
                                                   precisions[3]),
                            record['location']['state'],
                            record['location']['locality'],
                            record['composites'][0],
                            record['composites'][1],
                            record['composites'][2],
                            record['composites'][3],
                            record['location']['time_zone'])
         except:
             return None
     else:
         try:
             return Station(record['id'],
                            utils.ensure_precision(record['location']['point']['coordinates'][1],
                                                   precisions[1]),
                            utils.ensure_precision(record['location']['point']['coordinates'][0],
                                                   precisions[2]),
                            utils.ensure_precision(record['location']['point']['coordinates'][2],
                                                   precisions[3]),
                            '',
                            '',
                            '',
                            '',
                            '',
                            '',
                            '')
         except:
             return None