Skip to content

Commit

Permalink
Merge pull request #118 from EcoNet-NZ/use-creation-date
Browse files Browse the repository at this point in the history
Use creation date if observation date is null
  • Loading branch information
nigelcharman authored Oct 27, 2024
2 parents dcebf3c + 1c7601e commit 2d53fde
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions inat_to_cams/inaturalist_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@ def flatten(observation):
logging.exception(f'Skipping observation {observation.id} since it has no location set')
raise exceptions.InvalidObservationError

if not observation.observed_on: # could maybe use date submitted instead?
logging.warning(f'Skipping observation {observation.id} since it has no observation date set')
date_observed = observation.observed_on
if not date_observed:
logging.info('No observation date found, using creation date instead')
date_observed = observation.created_at

if not date_observed:
logging.warning(f'Skipping observation {observation.id} since it has no observation or creation date set')
raise exceptions.InvalidObservationError

inat_observation = inaturalist_observation.iNatObservation()
Expand All @@ -46,7 +51,7 @@ def flatten(observation):
inat_observation.height = INatReader.get_observation_value(observation, 'Height (m)')
inat_observation.area = INatReader.get_observation_value(observation, 'Area in square meters')
inat_observation.radius_surveyed = INatReader.get_observation_value(observation, 'Radius (m) of area surveyed')
inat_observation.observed_on = observation.observed_on.isoformat()[0:-6]
inat_observation.observed_on = date_observed.isoformat()[0:-6]

inat_observation.phenology = INatReader.get_observation_value(observation, 'Plant phenology->most common flowering/fruiting reproductive stage')

Expand Down

0 comments on commit 2d53fde

Please sign in to comment.