APSIMInitiative / ApsimX

ApsimX is the next generation of APSIM
http://www.apsim.info
Other
132 stars 161 forks source link

Creating a graph series filter using 'Date' doesn't work. #5333

Closed hol353 closed 4 years ago

hol353 commented 4 years ago

If in report you output: [Clock].Today as Date

and then try and filter a graph series on this date: [Date]>'2017-11-20'

You get an error saying that Date is ambiguous. This is because the _Checkpoints table has a 'Date' field as well as 'Report'. The workaround is to call the report variable something else e.g. 'Date2'

hol430 commented 4 years ago

Does the filter work if you use Report.Date?

hol353 commented 4 years ago

Nope. But

T.Date>'2017-11-20'

works. This is because T is used internally as an alias for the Report table. Not intuitive for the user though.

hol430 commented 4 years ago

This one ought to be fixable if we rework the query into a proper table join. Will add it to the to-do list, unless you've already fixed it(?).

hol353 commented 4 years ago

Nope I haven't touched it. I'll let you do it.

JJguri commented 4 years ago

I have created a variable called Das from the report ([Sorghum].Phenology.DaysAfterSowing as Das), I am trying to plot the residuals (from the PreObsDatabase) vs Das and this is not working because Das is not a column in the PreObsTable. Is there a way to include this column from the Report to the PredictedObservedTable? I am not sure if the filter by date is working. Untitled

hol430 commented 4 years ago

Yeah, that problem has been around a while and I'm not sure there's an easy fix on our end. To get this working on your end, I'd suggest copying the Das column from your report and pasting it into your observed file. If the column exists in both predicted and observed data, then it should be included in the PredictedObserved table, and the filter should work.

JJguri commented 4 years ago

Thanks @hol430 It is quite difficult because my DailyReport is providing daily data, and therefore daily values of Das, and my Observed file has specific dates for the measurements. So I need to calculate Das for each value in the Observed file manually because each simulation has a different sowing date. Is there a way to select X values from a data source and Y values from a different data source in the current XY graphs?

hol430 commented 4 years ago

Ah, yes that will be tricky. And no, it's not possible to get the X and Y values from different data sources. I guess a decent solution here might be for me to add a checkbox to the PredictedObserved UI which says something like "Include all columns in PredictedObserved table". When checked, all columns from both the observed and predicted data would be included in the merged table (normally, a column is only added to the merged table if it exists in both predicted and observed tables).

Only reason I haven't already added something like this is because it may slow down the PredictedObserved model if there are a lot of extra outputs in the report, but I guess if it's disabled by default then we could have the best of both worlds.

JJguri commented 4 years ago

Ok, so please keep me in the loop if this will be implemented. It also provides the option to plot Pre-Obs data vs other variables would be in the Observed file, e.g. sowing date, irrigation applied, N applied, etc. Specifically, I am interested in plot Pre-Obs vs radn and RadInt which are in the DailyReport (not in the observed file). If you implement that checkbox, would include the final table both, data from observed and the DailyReport?

hol430 commented 4 years ago

Yep - if DailyReport is your predicted table (ie the table you selected in the PredictedObserved UI) then yes, you will be able to plot anything in there against the data in the PredictedObserved table.

JJguri commented 4 years ago

Thanks @hol430

lie112 commented 4 years ago

If you're good with SQL script writing you could create a SQLite script (using a CLEM.CustomQuery) that will combine your two tables into a single VIEW in the database that you can plot or analyse the same as a table.

JJguri commented 4 years ago

thanks @lie112 for the recommendation. I will have a look and try to advance with this.

hol430 commented 4 years ago

There should be a new upgrade out which includes this fix, so if you upgrade to latest, the above filter ought to work, after you tick the extra box in the predictedobserved node and rerun it.

JJguri commented 4 years ago

Thanks @hol430 already using it!

hol430 commented 4 years ago

@hol353 why does the _Checkpoints table even have a Date column? As far as I can see this date column is never used. Seems like the simplest solution would be to get rid of it.

hol353 commented 4 years ago

Yes the Date column in _Checkpoints can be removed.