ua-snap / shiny-apps

R Shiny apps
234 stars 191 forks source link

CMIP3 / CMIP5 app - Add historical non-GCM data #32

Closed leonawicz closed 10 years ago

leonawicz commented 10 years ago

Begin by adding CRU data to the app.

The data should be compiled similarly to that of the GCMs such that CRU can be comparatively analyzed in the plots along with the GCMs. This will be incredibly complicated! For example, CRU has one "scenario", call it "historical", and that scenario is mutually exclusive of all the GCM scenarios. The time period for CRU is a subset of the time period of each GCM - this is as GOOD as it gets, a subset! CRU does not belong to either CMIP phase. There is nothing that inherently lends the app to plotting CRU along with GCMs in ALL the same ways. It just doesn't make sense.

Consider the following:

  1. A checkbox for toggling CRU overlay on and off when plotting strict time series data, where the x-axis is either month, year, or decade.
  2. Force time window (year slider and decade menu) to the shorter period of time common to CRU and the GCMs, which is 1901 to 2009. This will help avoid many programming problems as well as prevent idiotic interpretations of poorly constructed graphs. This may also facilitate an opening for inclusion of CRU in non-time series plots such as the scatter plot of T ~ P and plots where the x-axis represents various categorical variables.
  3. Special color for CRU (e.g., black) when grouping/coloring by model with CRU included in the comparison, to provide additional visual differentiation. This may prove to be too much of a coding hassle for the value though. Perhaps not, but not a priority.
  4. It may be prohibitive to include CRU in among the menus for GCM models, or to have a historical option in the scenarios menus. Nor would it make sense, because it would only go in one menu, and it does not belong to either the CMIP3 group or the CMIP5 group. It is best to use the checkbox option for toggling CRU on and off. Perhaps expand the meaning of this beyond time series overlay to general inclusion by merging the CRU data frame with an identically arranged/subsetted GCM data frame (requiring 2. above as well).
  5. CRU should be treated as a "model" to facilitate its interaction in plots with other models, but it should be treated as a "scenario" among scenarios. Conceivably, it should also be treated as a CMIP phase among the two CMIP phases. This may be problematic. Potentially, when compiling CRU data, it could be compiled like the GCM data following data extraction by shapefile such that Phase=CRU, Scenario=CRU, and Model=CRU redundantly. Also potentially, the data drame structure could have columns of Phase=Obs, Scenario=Historical, and Model=CRU. it is hard to anticipate how either of these will interact with the GCM data once merged.
leonawicz commented 10 years ago

First iteration of CRU 3.1 historical temperature and pecipitation data compiled for the app. .RData files for regional and city data, respectively, have been added to the serverHead.R script to be loaded into the global environment at app launch. Next step will involve basic integration of an "overlay CRU" input widget with the various plotting functions, controlling how and under what circumstances CRU data overlay will occur.

leonawicz commented 10 years ago

CRU 3.1 data overlay capability has been added to plot tab one. Preliminary design. Basic functionality. Currently limitations with supplementing plot legend with CRU information.

Option to overlay CRU currently shows as a checkboxInput control in the data subsetting panel. This is because it involves subsetting operations just like the GCM data do. But it would make more sense for the user to see the control in the plot options panel. Consider moving it there, and having the subsetting be done implicitly and automatically for CRU in addition to GCMs.

leonawicz commented 10 years ago

CRU 3.1 data overlay appears to work for plot tab one under all conditions (points, mean lines, subject lines, jitter, different numbers of factor levels for grouping and faceting variables).

Must treat CRU as a 'model' in some programmatic respects. This means when faceting by model, CRU will gets its own panel rather than continue to overlay the other models.

Legend information supplement seems good enough when plotting lines. Nothing appears for points alone. This is fine for now.

Circle with black fill and red border is used for CRU points. This works well because when no grouping variable is present, GCM data show as open circles with black border, but when grouping variable is selected, GCM data show as various colored circles with black border, but never black and never with a red border. Also, CRU lines show as red when (no group variable) GCM data are shown with black lines and black when (group variable chosen) GCM data are shown with colored lines. Furthermore, when switching to barplots for precip, CRU overlays are still as points and/or lines, not bars. Bars are black when no grouping variable is chosen, and CRU points may overlay bars, but are still visible due to the red border.

Next step, apply similar code to plotting function for plot tab two.

leonawicz commented 10 years ago

Preliminary CRU 3.1 overlay capability added to plot tab two.

leonawicz commented 10 years ago

Plot tab two satisfactory. Plot tab three partial progress. Problem integrating CRU 3.1 overlay with boxplot option.

leonawicz commented 10 years ago

Plot tab three: sort out issues with points/no points over boxplots when including CRU 3.1 overlay.

When using boxplots, CRU 3.1 is appended to GCM data frame, as opposed to general strategy of separate data frame plotting.

leonawicz commented 10 years ago

Appending has become the strict strategy for this plot tab.

leonawicz commented 10 years ago

This is tentatively completed. May be reopened later or a new, related, but more specific issue opened.