Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate ORNL DAAC Identify calls #10

Closed
cmungall opened this issue Jul 22, 2021 · 4 comments
Closed

Integrate ORNL DAAC Identify calls #10

cmungall opened this issue Jul 22, 2021 · 4 comments
Assignees

Comments

@cmungall
Copy link
Collaborator

The goal is to implement methods within the NMDC sample-annotator framework to access DAAC APIs, and transform the results into json objects conforming to the JSON schema. Broadly there are two types of calls, those that produce (1) QUantityValues, e.g. elevation (2) qualitative, e.g. soil types.

@StantonMartin started on code here: https://github.com/StantonMartin/Identify/

However, this functionality will not be implemented as a standalone script, but in sample-annotator framework. Before attempting to implement this ticket, the implementor must familiarize themselves with the code in this repo, see the README and the unit tests.

As a stub example, the existing codebase uses the google maps API to query for elevation.

See code:

def get_elevation(self, latlon: LATLON = (40.714224, -73.961452)):
results = self.get_client().elevation(latlon)
return results

and the unit test:

def test_elevation(self):
ge = GeoEngine()
if os.path.exists(KEYPATH):
ge.load_key(KEYPATH)
mtEverestCoord = (27.9881, 86.9250)
e = ge.get_elevation(mtEverestCoord)
print(e)
# Wikipedia says 8,848.86m
e0 = e[0]
assert e0.get('elevation') > 8800
assert e0.get('elevation') < 8900

You can see how this is implemented within the main sample annotator here:

def perform_geolocation_inference(self, sample: SAMPLE, report: AnnotationReport):
"""
Performs inference using geolocation information
"""
# TODO: Stan to populate
ll_str = sample.get(KEY_LAT_LON, None)
if ll_str is None:
report.add_message(f'No lat_long specified',
severity=3,
category=Category.MissingCore)
return
try:
lat_lon = tuple([float(x.strip()) for x in ll_str.split(' ')])
except:
report.add_message(f'Incorrect format for lat_lon: {ll_str}', severity=3)
return
sample[KEY_LAT_LON] = {'latitude': lat_lon[0], 'longitude': lat_lon[1]}
ge = self.geoengine
if ge is None:
report.add_message('Skipping geo-checks', severity=0)
return
logging.info('Using geoengine')
elevs = ge.get_elevation(lat_lon)
if len(elevs) != 1:
report.add_message(f'Something went wrong, elevs = {elevs}')
if len(elevs) > 0:
elev = elevs[0].get('elevation')
res = elevs[0].get('resolution')
if KEY_ELEV in sample:
curr = sample.get(KEY_ELEV)
if curr.has_unit == 'meter':
if abs(curr.has_value - elev) > res:
report.add_message(f'Conflicting values for elevation; current: {curr} Googlemaps: {elev} +/- {res}')
else:
report.add_message(f'Filling in missing value for elevation {elev}',
was_repaired=True)
sample[KEY_ELEV] = {'has_unit': 'meter',
'has_numeric_value': elev}

[ADDING MORE LATER...]

For qualitative data we will curate mapping tables, see my PR here: StantonMartin/Identify#1

@ssarrafan ssarrafan added this to the Sprint 5 milestone Aug 3, 2021
@ssarrafan
Copy link

@cmungall @dehays let me know if this should be re-assigned to Stan or if I should create a new issue for Stan related to this and the meeting you had with him last week.

@ssarrafan ssarrafan modified the milestones: Sprint 5, Sprint 6 Sep 1, 2021
@ssarrafan
Copy link

@cmungall @StantonMartin should this issue be closed, moved to the backlog or moved to the October sprint?

@ssarrafan ssarrafan modified the milestones: Sprint 6, Sprint 7 Oct 1, 2021
@ssarrafan ssarrafan removed this from the Sprint 7 milestone Oct 29, 2021
@ssarrafan
Copy link

No updates on this since August so I've added the backlog label and removed from the project board.
FYI @cmungall @emileyfadrosh

@StantonMartin
Copy link
Contributor

Integration complete. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants