ImperialCollegeLondon / paricia

Hydroclimatic data collection and information system
https://imperialcollegelondon.github.io/paricia/
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

NivelFuncionTabla and nivelfunctiontabla #42

Open dandavies99 opened 2 years ago

dandavies99 commented 2 years ago

@pxjacomex - What do these do? Should the model be defined in models.py? It's hard for us to understand because the function is basically pure SQL.

pxjacomex commented 2 years ago

@dandavies99 There are two models associated with the function for converting water level to flow: CurvaDescarga, and NivelFuncion.

NivelFuncion: Stores the conversion function in a string field using postgres arithmetic syntax, for example: 0.35(H^2.19) + 1.76H , where H is the water level in centimeters. This function is multi-level for a single station, so you can have something like this:

curvadescarga_id      level       function
1                     30          2.14*H                        # applies from  0 to 30 cm
1                    120          0.35*(H^2.19) + 1.76*H        # applies from 30 to 120 cm

CurvaDescarga model associates the group of functions to a station in a given date (start date)

All the postgres code about CurvaDescarga/NivelFuncion you see in the project is to convert water level to flow trying to speeding up the calculations when massive amounts, and because there was also required that some of them applies automatically, triggers were made when:

If you would like to try the code for converting water level to flow using this multilevel approach I recommend removing the triggers and implementing it manually and see if its convenient for you.

Please let me know if you need further explanation.

dandavies99 commented 2 years ago

Thanks @pxjacomex, I understand what these mean now. I'll leave this issue open so we can return to it when we want to implement this part.