CANFLUX / Calculation_Procedures

Ini files for cleaning under ../Database/Calculation_Procedures
0 stars 1 forks source link

Uniform stage 3 procedure & address issues raised by June and Sara #85

Closed sknox01 closed 5 months ago

sknox01 commented 6 months ago

@June-Skeeter & @sknox01

Below are the issues raised by June:

I ran the third stage cleaning procedures for BBS which has brough up two issues we should think about. Running this from Matlab: fr_automated_cleaning([2023 2024],{'BBS'},[1 2 7 8]); fails to output ThirdStage data in for two reasons.

1) ThirdStage_REddyProc.R has a number of variables hard coded in it, including "FCH4", which isn't measured at BBS. Commenting out FCH4 is easy enough to do for a single manual BBS run, but will prove cumbersome for automation. This is a boundary case for our group, but if there is intention to have other sites running these procedures, there are plenty of other sites that don't measure CH4. In the spirit of modularity, I feel like these hard coded variables should probably be drawn from the .ini files rather than from the code.

2) Working around issue 1 by removing the FCH4 variable, the procedure runs fine for 2024, but fails for 2023. The reason is that the default behavior setup in the matlab call to runThirdStageCleaningREddyProc(yy(1),SiteId,'fast',2) defaults to using the current year and data from the previous year, which doesn't exist for the first year of the site. Setting to 1, it works fine. Alternatively, leaving it set to 2 and creating a dummy "pre-first year" folder by calling fr_automated_cleaning([2022],{'BBS'},[1 2]); is a hack that can work around the issue. As long as 2022/clean_tv exits and the traces are present (can be all NAN) it "works". The root of the issue I think is in the Biomet.Net/R/database_functions/read_database.R > the program crashes if any of the years requested are not available in the database for the specific site. Unless this behavior is desired/intentional for other applications, I can work out a fix for it.

Sara: add ET to the third stage.

sknox01 commented 6 months ago

Also, consider storage terms for fluxes.

znesic commented 6 months ago

I have a vague recollection that June and I talked about #2 and that this was not an issue as long as the year when the site was established is defined properly in the BBS_ThirdStageini.R file: # Year the site was established estYear <- 2023_

June-Skeeter commented 6 months ago

@sknox01 @znesic > I have added functional stage 3 files for: BB, BB2, BBS. You'll notice that the three files area almost identical except that they contain different station metadata and the BBS file has some minor adjustments due to the lack of CH4 data.

June-Skeeter commented 5 months ago

I think we can consider this closed as the gist of it has been implemented.