osmose-model / osmose-web-api

Web service that generates Osmose configuration files from data sources like Fishbase and SeaLifeBase. Used by https://www.config.osmose-model.org .
MIT License
2 stars 2 forks source link

Providing estimates for the Amax parameters #140

Closed agruss2 closed 6 years ago

agruss2 commented 6 years ago

@jhpoelen We now have all the pieces of information for providing estimates for the Amax parameters used in OSMOSE (the "species.vonbertalanffy.threshold.age.sp*" parameters in OSMOSE), i.e., the threshold ages below which a linear growth model is used to calculate mean length increase in OSMOSE (and above which a von Bertalanffy growth model is used to calculate mean length increase in OSMOSE).

Here is how I would like the API to proceed, please: (1) If in the "POPLW" table, an estimate is available for the "LengthMin" parameter, then the API should calculate Amax as follows: Amax = to + ( log(Loo) - log(Loo - LengthMin ) / K ; where "to", "Loo" and "K" are von Bertalanffy growth parameters provided in the "POPGROWTH" table.

(2) (If there is no estimate available for the "LengthMin" parameter in the "POPLW" table OR parameters are not available in the "POPGROWTH" table to make the calculations described in (1)) AND the maximum age of the species under consideration is greater than 2 years (i.e., if the "LongevityWild" parameter in the "SPECIES" table is greater than 2 years), then the API should set Amax to 1 year.

(3) (If there is no estimate available for the "LengthMin" parameter in the "POPLW" table OR parameters are not available in the "POPGROWTH" table to make the calculations described in (1)) AND the maximum age of the species under consideration is lower than 2 years (i.e., if the "LongevityWild" parameter in the "SPECIES" table is lower than 2 years), then the API should calculate Amax as follows: Amax = LongevityWild * (AgeMin/AgeMax) where "AgeMin" and "AgeMax" are provided in the "ESTIMATE" table.

(4) (If there is no estimate available for the "LengthMin" parameter in the "POPLW" table OR parameters are not available in the "POPGROWTH" table to make the calculations described in (1)) AND if there is no estimate for the "LongevityWild" parameter in the "SPECIES" table, then the API should set Amax to 1 year.

(5) (If there is no estimate available for the "LengthMin" parameter in the "POPLW" table OR parameters are not available in the "POPGROWTH" table to make the calculations described in (1)) AND an estimate is available for the "LongevityWild" parameter in the "SPECIES" table AND there are no estimates available for the "AgeMin" and "AgeMax" parameters in the "ESTIMATE" table, then the API should set Amax to LongevityWild/2.

Important: Because, in some (rare) instances, "AgeMin" is negative in the "ESTIMATE" table, the API should check the value of "AgeMin" before making any calculations --> If AgeMin is negative, then the API should set AgeMin to 0.01.

Many thanks!!

jhpoelen commented 6 years ago

@agruss2 I've implemented a first pass at what you described above. Please verify.

agruss2 commented 6 years ago

@jhpoelen Many thanks for that. However, I ran a test for the Iceland Shelf/Sea ecosystem and I cannot get the zip file. The UI kept saying "Preparing configuration ..." and the zip file never appeared, and, at some point, the UI crashed.
I suspect that this is due to the fact that heavy computations are going on in the background. I think that it would be better to calculate "to + ( log(Loo) - log(Loo - LengthMin ) / K" and "LongevityWild * (AgeMin/AgeMax)" ourselves and to incorporate the resulting estimates in the "ESTIMATE" table rather than to ask the API to make the calculations. What do you think? If you feel the same, then I will close the present GitHub issue and open a new one. Thanks a lot!

jhpoelen commented 6 years ago

@agruss2 I was able to reproduce the website crash using chrome browser. In an attempt to figure out the root cause, I captured the parameters transferred from the web UI to the API and saved it to a json file (see https://github.com/jhpoelen/fb-osmose-bridge/commit/3dbabac1a492e374aab01c8c155025639525903d ). Then, I generated the osmose configuration from the command line using that json file (see https://raw.githubusercontent.com/jhpoelen/fb-osmose-bridge/3dbabac1a492e374aab01c8c155025639525903d/src/test/resources/com/github/jhpoelen/fbob/exampleConfigIceland.json) -

curl -X POST --data @exampleConfigIceland.json --header "Content-Type:application/json;charset=UTF-8" https://fbob.herokuapp.com/v2/osmose_config.zip > iceland_osmose_config.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  217k    0  202k  100 15461  23891   1784  0:00:08  0:00:08 --:--:-- 35264

Then, I unpacked the resulting zip archive and found that:

$cat osm_param-species.csv | grep vonbertalanffy
species.vonbertalanffy.threshold.age.sp0;1.140
species.vonbertalanffy.threshold.age.sp1;-0.214
species.vonbertalanffy.threshold.age.sp2;0.863
species.vonbertalanffy.threshold.age.sp3;1.779
species.vonbertalanffy.threshold.age.sp4;2.665
species.vonbertalanffy.threshold.age.sp5;0.745
species.vonbertalanffy.threshold.age.sp6;4.978
species.vonbertalanffy.threshold.age.sp7;4.219
species.vonbertalanffy.threshold.age.sp8;2.276
species.vonbertalanffy.threshold.age.sp9;-1.714
species.vonbertalanffy.threshold.age.sp10;0.603
species.vonbertalanffy.threshold.age.sp11;-0.153
species.vonbertalanffy.threshold.age.sp12;2.513
species.vonbertalanffy.threshold.age.sp13;0.198
species.vonbertalanffy.threshold.age.sp14;1.000
species.vonbertalanffy.threshold.age.sp15;1.000
species.vonbertalanffy.threshold.age.sp16;0.833
species.vonbertalanffy.threshold.age.sp17;-0.795
species.vonbertalanffy.threshold.age.sp18;0.292
species.vonbertalanffy.threshold.age.sp19;0.236
species.vonbertalanffy.threshold.age.sp20;1.000

Showing that (a) the osmose configuration was created and (b) contained non default vonbertalanffy values. In other words, the crash is a separate issue, which I'll report shortly.

I've attached the resulting iceland_osmose_config.zip file to this issue.

iceland_osmose_config.zip

agruss2 commented 6 years ago

@jhpoelen Thanks a lot. The problem probably came from my laptop. I therefore closed #143.

agruss2 commented 6 years ago

@jhpoelen I am happy with most of the parameter values that were generated by the API, except the negative ones. Therefore, could we please modify rule no. 5 and add one additional rule so that none of the Amax parameters are negative?

Here is an updated list of instructions for the API, please: (1) If in the "POPLW" table, an estimate is available for the "LengthMin" parameter, then the API should calculate Amax as follows: Amax = to + ( log(Loo) - log(Loo - LengthMin ) / K ; where "to", "Loo" and "K" are von Bertalanffy growth parameters provided in the "POPGROWTH" table.

(2) (If there is no estimate available for the "LengthMin" parameter in the "POPLW" table OR parameters are not available in the "POPGROWTH" table to make the calculations described in (1)) AND the maximum age of the species under consideration is greater than 2 years (i.e., if the "LongevityWild" parameter in the "SPECIES" table is greater than 2 years), then the API should set Amax to 1 year.

(3) (If there is no estimate available for the "LengthMin" parameter in the "POPLW" table OR parameters are not available in the "POPGROWTH" table to make the calculations described in (1)) AND the maximum age of the species under consideration is lower than 2 years (i.e., if the "LongevityWild" parameter in the "SPECIES" table is lower than 2 years), then the API should calculate Amax as follows: Amax = LongevityWild * (AgeMin/AgeMax) where "AgeMin" and "AgeMax" are provided in the "ESTIMATE" table.

(4) (If there is no estimate available for the "LengthMin" parameter in the "POPLW" table OR parameters are not available in the "POPGROWTH" table to make the calculations described in (1)) AND if there is no estimate for the "LongevityWild" parameter in the "SPECIES" table, then the API should set Amax to 1 year.

(5) (If there is no estimate available for the "LengthMin" parameter in the "POPLW" table OR parameters are not available in the "POPGROWTH" table to make the calculations described in (1)) AND an estimate is available for the "LongevityWild" parameter in the "SPECIES" table AND there are no estimates available for the "AgeMin" and "AgeMax" parameters in the "ESTIMATE" table, then the API should set Amax to LongevityWild/10.

(6) If the API has set Amax to a negative value, then the API should replace this negative value with: LongevityWild/10.

Many thanks!

agruss2 commented 6 years ago

@jhpoelen Many thanks for having worked on this. There is only one thing that needs to be corrected now. If you look at the very last comment I made above, (5) and (6) mention "LongevityWild/10" and not "LongevityWild/2". Could you please correct for this? Thank you very much!

agruss2 commented 6 years ago

@jhpoelen I just ran a test for the Iceland Shelf/Sea ecosystem and noticed that the present issue has been solved. Many thanks !! I can therefore close the present issue now.