Skip to content

Commit

Permalink
#30: generalising some metadata insertion
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenwh committed Aug 28, 2019
1 parent d836bd1 commit ca7ee3b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
7 changes: 6 additions & 1 deletion geospaas_wind/management/commands/process_sentinel1_wind.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Command(BaseCommand):
--date <date>: Select Sentinel-1 datasets by date (yyyy-mm-dd)
--url <str>: Select Sentinel-1 dataset by url
--force-reprocessing: Force reprocessing of SAR wind
--data-center: GCMD provider shortname
--naming-authority: Dataset naming authority
Example:
Process all Sentinel-1 datasets on 2019-07-01 (the datasets must have been added to the
Expand All @@ -31,6 +33,8 @@ def add_arguments(self, parser):
parser.add_argument('--force-reprocessing', action='store_true', default=False,
help='Force reprocessing')
parser.add_argument('--url', type=str, default='', help='URL of OPeNDAP dataset')
parser.add_argument('--data-center', type=str, default='', help='GCMD provider shortname')
parser.add_argument('--naming-authority', type=str, default='', help='Dataset naming authority')


def handle(self, *args, **options):
Expand All @@ -55,7 +59,8 @@ def handle(self, *args, **options):
except MultipleObjectsReturned:
failed += 1
continue
wds, cr = WindDataset.objects.process(dsuri.uri, force=options['force_reprocessing'])
wds, cr = WindDataset.objects.process(dsuri.uri, force=options['force_reprocessing'],
data_center=options['data-center'], naming_authority=options['naming_authority'])
if cr:
self.stdout.write('Successfully processed (%d/%d): %s\n' % (i+1, numds, dsuri.uri))
ingested += 1
Expand Down
6 changes: 4 additions & 2 deletions geospaas_wind/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ def process(self, uri, force=False, *args, **kwargs):
wds = Dataset.objects.filter(dataseturi__uri__contains=fn)[0]
return wds, False

import ipdb
ipdb.set_trace()
thredds_fn = os.path.join(settings.PRODUCTS_ROOT, fn)
wind_uri = 'file://localhost' + thredds_fn

Expand Down Expand Up @@ -67,8 +69,8 @@ def process(self, uri, force=False, *args, **kwargs):
#w.reproject(d, tps=True)

# Set global metadata
metadata['data_center'] = json.dumps(pti.get_gcmd_provider('nersc'))
metadata['naming_authority'] = 'no.nersc.sios_infranor'
metadata['data_center'] = json.dumps(pti.get_gcmd_provider(kwargs.pop('data_center', 'nersc')))
metadata['naming_authority'] = kwargs.pop('naming_authority', 'no.nersc.sios_infranor')
metadata['project'] = 'SIOS InfraNor'
metadata['entry_title'] = 'Wind field from '+os.path.basename(uri)
metadata.pop('file_creation_date')
Expand Down
38 changes: 23 additions & 15 deletions notebooks/Process wind from Sentinel-1 NRCS.ipynb

Large diffs are not rendered by default.

0 comments on commit ca7ee3b

Please sign in to comment.