Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
allow a simpler way of providing the platfrom and instrument metadata
  • Loading branch information
mortenwh committed Mar 27, 2021
commit 8c8ae05608293c7d4790d24ab3eaa03b94c1d1ff
20 changes: 15 additions & 5 deletions geospaas/nansat_ingestor/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,22 @@ def get_or_create(self,
# get metadata from Nansat and get objects from vocabularies
n_metadata = n.get_metadata()

entry_id = n_metadata.get('entry_id', None)
entry_id = n_metadata.get('entry_id', n_metadata.get('id', None))
# set compulsory metadata (source)
platform, _ = Platform.objects.get_or_create(
json.loads(n_metadata['platform']))
instrument, _ = Instrument.objects.get_or_create(
json.loads(n_metadata['instrument']))
pp = n_metadata['platform']
try:
pp_dict = json.loads(pp)
except json.JSONDecodeError:
pp_entry = [elem.strip() for elem in pp.split('>')]
pp_dict = pti.get_gcmd_platform(pp_entry[-1])
platform, _ = Platform.objects.get_or_create(pp_dict)
ii = n_metadata['instrument']
try:
ii_dict = json.loads(ii)
except json.JSONDecodeError:
ii_entry = [elem.strip() for elem in ii.split('>')]
ii_dict = pti.get_gcmd_instrument(ii_entry[-1])
instrument, _ = Instrument.objects.get_or_create(ii_dict)
specs = n_metadata.get('specs', '')
source, _ = Source.objects.get_or_create(platform=platform,
instrument=instrument,
Expand Down