Example #1
0
def push_projection_info(params, context, rundate):
    taxon_name = None
    common_name = None
    conserve_status = None

    # load the species metatadata
    mdfilepath = os.path.join(params['env']['inputdir'], params['params'][
                              'species_occurrence_dataset']['uuid'], 'ala_metadata.json')
    metadata = json.load(open(mdfilepath))

    # Get scientific name
    taxon_name = (metadata.get('classification', {}).get('scientificName')
                  or metadata.get('taxonConcept', {}).get('nameString')
                  or metadata.get('taxonConcept', {}).get('nameComplete'))

    # Get common name
    for record in metadata['commonNames']:
        if record['nameString'] is not None:
            common_name = record['nameString']
            break

    # Get conservation status
    records = metadata.get('conservationStatuses', {})
    for key in records.keys():
        if records[key].get('status', None):
            conserve_status = records[key].get('status')
            break

    md = {"common_name": common_name,
          "scientific_name": taxon_name,
          "uuid": metadata.get('taxonConcept', {}).get('guid'),
          "kingdom": metadata.get('classification', {}).get('kingdom'),
          "class": metadata.get('classification', {}).get('class'),
          "family": metadata.get('classification', {}).get('family'),
          "conservationStatuses": conserve_status,
          "run_date": rundate,
          "title": common_name or taxon_name,
          "description": "Species Distribution Model and Climate Change projection of {} using Maxent algorithm.".format(common_name or taxon_name),
          "current_proj_url": os.path.join(params['result']['results_dir'], 'current_projection.png'),
          "future_proj_url": os.path.join(params['result']['results_dir'], '2085_projection.png'),
          "algorithm": "Maxent",
          "current_climate": "Australian Current Climate 1976 to 2005, 30arcsec (~1km)",
          "future_climate": "Australian Climate Projection RCP85 based on UKMO-HADGEM1, 30arcsec (~1km) - 2085",
          "gcm": "UKMO-HADGEM1",
          "emission_scenario": "RCP85",
          "projection_year": "current, 2085"
          }

    move_tasks = []
    srcpath = os.path.join(params['env']['outputdir'], 'proj_metadata.json')
    with open(srcpath, 'w') as f:
        f.write(json.dumps(md, indent=4))

    destpath = os.path.join(params['result']['results_dir'], 'proj_metadata.json')
    move_tasks.append(('file://' + srcpath, destpath))
    datamover.move(move_tasks, context)
Example #2
0
def transfer_projections(params, context, filelist):
    # TO-DO: Catch an exception if there isn't a .tif output file
    # Fetch a tiff file that isn't a clamping mask
    move_tasks = []
    for srcpath in filelist:
        fname = 'current_projection.png'
        if not os.path.basename(srcpath).startswith('proj_current'):
            fname = '2085_projection.png'
        destpath = os.path.join(params['result']['results_dir'], fname)
        move_tasks.append(('file://' + srcpath, destpath))
    datamover.move(move_tasks, context)
Example #3
0
def write_status_to_nectar(params, context, status):

    move_tasks = []
    # TODO: Figure out where the status file lives
    srcpath = os.path.join(params['env']['outputdir'], 'state.json')
    with open(srcpath, 'w') as f_json:
        f_json.write(json.dumps({u'status': status,
                                 'jobid': context['jobid']}, indent=4))

    destpath = os.path.join(params['result']['results_dir'], 'state.json')
    move_tasks.append(('file://' + srcpath, destpath))
    datamover.move(move_tasks, context)