-
Notifications
You must be signed in to change notification settings - Fork 10
Beta version of phenology features #356
Description
Here is the proposal:
API
A new API endpoint will be built.
https://www.gallformers.org/gall/{id}/pheno
where {id} is some potential Gall ID.
Three operations will be supported:
GET:
Fetches the pheno data for the given gall.
- Will return
404if there is no Gall with the givenid. - Will return
200and the pheno data for the passed inidin the body as the JSON structure defined below.
POST
Adds or updates the pheno data for the given gall.
- Will return
401if the call is not properly authorized and authenticated. (Details TBD) - Will return
400if there is no Gall with the givenid - Will return
200if the call is properly authorized, authenticated, theidis valid, and the passed in JSON body conforms to the structure defined below
DELETE
Deletes the pheno data for the given gall.
- Will return
401if the call is not properly authorized and authenticated. (Details TBD) - Will return
400if there is no Gall with the givenid - Will return
200if the call is properly authorized, authenticated, theidis valid, and the passed in JSON body conforms to the structure defined below
Under no circumstance will any of the API calls return 418
The JSON structure:
{
{
"id": 0,
"developing_start_slope": "-0.015",
"developing_start_yint": "562",
"developing_end_slope": "-0.015",
"developing_end_yint": "900",
"collection_viable_start_slope": "-0.015",
"collection_viable_start_yint": "950",
"collection_viable_end_slope": "-0.015",
"collection_viable_end_yint": "950",
"emergence_start_slope": "-0.015",
"emergence_start_yint": "1100",
"emergence_end_slope": "-0.015",
"emergence_end_yint": "1222",
"min_latitude": 0.0,
"max_latitude": 0.0
}All fields are JSON numbers. All must be valid numbers in proper JSON format. id, min_latitiude, and max_latitiude must never be null and must be passed in. All of the other values are optional, though unexpected things may happen if a value is passed for one of a pair but not the other.
User Facing UI
The initial POC implementation will be new page found at https://www.gallformers.org/pheno and linked from the front page and possibly from the nav bar (TBD).
The UI will show:
- an input box for Latitude. This is constrained to latitudes in the range of 0 to 60
- an input box for the Host Oak. This is the typical dropdown/typeahead component. Only a single Host can be chosen.
Once both of the above are filled with valid data a search will be run and a list of galls will be returned in a table with the following rows:
- Gall - clickable will navigate to the main Gall page for that species
- Viable Collection Start
- Viable Collection End
- Emergence Start
- Emergence End
The table will be sortable on any of the rows. All rows will be displayed with no pagination.
Backend
The new data will be stored in a new pheno table.
CREATE TABLE gallpheno (
id INTEGER NOT NULL,
rearing_viable_start_slope REAL NOT NULL,
rearing_viable_start_yint REAL NOT NULL,
rearing_viable_end_slope REAL NOT NULL,
rearing_viable_end_yint REAL NOT NULL,
collection_viable_start_slope REAL NOT NULL,
collection_viable_start_yint REAL NOT NULL,
collection_viable_end_slope REAL NOT NULL,
collection_viable_end_yint REAL NOT NULL,
emergence_viable_start_slope REAL NOT NULL,
emergence_viable_start_yint REAL NOT NULL,
emergence_viable_end_slope REAL NOT NULL,
emergence_viable_end_yint REAL NOT NULL,
min_latitude REAL NOT NULL,
max_latitude REAL NOT NULL,
FOREIGN KEY (id) REFERENCES species (id) ON DELETE CASCADE
);The algorithm to convert a latitude plus phenology event to a date is:
const date = new Date(new Date().getFullYear(), 0, (latitude - yint) / slope);Questions
- How to authenticate against the API from R - @jeffdc
- How should the new pheno page be accessed?
- What should the latitude constraints be in the UI?
Original Text
Not sure exactly what the best way to go about this would be so feel free to make countersuggestions (or just tell me we should wait for a spring launch) but since I do already have some data ready and can quickly get a fair amount more, I thought it might be cool to find a way to make it available for Gall Week and try to get some feedback.
Regardless of how we present the info to the user, this will necessarily involve creating some kind of import UI for me to add my data to GF.
Current thinking is that this should be in the form of slope/y-intercept parameters for doy-latitude lines, two sets each (start and end) for each variable of interest: rearing viability (we have very little data for this at this point but it's also the most useful where it is available; not a priority but flagging it here in case it's easier to add now), maturation, and developing.
It may also make sense for me to provide something like min-max latitudes in which these lines can be considered reasonable inferences, so we aren't implying people should look for galls way outside their ranges? (possibly longitudes as well if we can find some way to implement that with the state/province ranges already in the db?)
In terms of presenting this to the user, I think putting graphs on gall pages buries the relevant info a bit (though obviously a long-term goal). What I'm envisioning is either a stripped-down alternative to the ID page or an addition to it. The user enters their latitude and a host plant (trialing this exclusively on oaks for now) and we'll calculate the dates that correspond with that latitude for a list of galls meeting those criteria.
So eg I would enter Q virginiana, latitude = 30.2, and the site would return something along the lines of (fake dates for illustration):
