ncsco / pinemap-dss-help

Issue tracker for PINEMAP DSS
0 stars 0 forks source link

Add a mask for the PINEMAP region #87

Closed daviswx closed 8 years ago

daviswx commented 8 years ago

Goal: On the Summer Dryness tool, values from Texas westward should be masked out since the Summer Dryness Index was never intended to be used in those environments.

Completed Task: Ryan created this mask and it has been added to the DSS. For now, it will just be used for the Summer Dryness Index tool, but it can be easily added to other tools with one line of code.

Completed Task: The map code has been updated so that the mask and boundaries layers are removed and re-added to the map whenever the map display is changed, so they will always be on top.

To-Do: When the map is clicked, use a GetFeatureInfo request to see if the clicked location is within the masked layer. If so, treat it as invalid/no data available.

Discussion Point: Should the map be re-centered by default so that the masked region does not appear, as shown below? And should we have tool-specific default map positions?

image

daviswx commented 8 years ago

For the discussion point, my concerns with this are (a) if someone scrolls westward, then they really might think that the map data isn't loading, and (b) I'd rather not have different starting map views for each tool. Consistency from one tool to the next is more important, IMO.

daviswx commented 8 years ago

An error message is now displayed on the Summer Dryness tool if the user clicks in the masked region.

hadinon commented 8 years ago

Honestly I think it looks cleaner when it is re-centered but I understand your concerns. So, I'm fine with having it the same centering as other tools for consistency. We should explain why there is no data for the west coast in the title tooltip, which I'll work on as part of #83.

hadinon commented 8 years ago

I've been playing around with clipping one of the summer dryness index files (historical one) to the native loblolly range as Harold suggested and finally had success! Just from viewing it as a PDF, IMO it looks much better than the current masked maps on the DSS (west coast mask only) but I'll email you a link to the test file and maybe we can compare the two to see which one we like best within the DSS framework?

daviswx commented 8 years ago

The masked historical Summer Dryness Index map is in place on the DSS now. Check it out there, and here's a screenshot of it, too:

image

hadinon commented 8 years ago

Thanks. I like it! What do you think? When I overlaid the loblolly native range layer, it looked like it matched up really well. In the PDF rendition of the netCDF, there are a few loblolly "islands" a bit to the west but they're not showing up on the DSS. Is that because your script is currently set up to ignore areas to the west of Ryan's masked region? I'm sure you will update that if we chose to go this route but wanted to mention it. :) If you think it looks good, I can run the script on the other tool files and let you know when they're finished.

daviswx commented 8 years ago

I'm fine with it, but I do wonder if there's value in seeing data slightly outside of this range, e.g., in central Tennessee, where loblolly could probably be grown but just isn't at the moment. Of course, this is the same question we have about the model output: How far outside of the native range should we show?

Have you gotten Ryan's thoughts about this masked version yet? I'd be curious to know how large of a mask he prefers.

daviswx commented 8 years ago

I think I figured out why it's showing values of 0 when you click on the historical map.

When you click a point, it's doing a quick calculation based on the clicked lat/lon to calculate the MACA i and j values. But with the data masked before it's stored in the NetCDF, I'm guessing that throws off the i/j values.

Is there any way to store missing values (like 9999) for points beneath the mask? That way, the i and j values would stay the same.

hadinon commented 8 years ago

OK this is so weird. The i,j values are definitely off when investigating this with the two files in Godiva. The weirdest part is that the number of i,j's is the same in the original and clipped file. So, I'm going to try the clip a different way and see what happens!

hadinon commented 8 years ago

Update on this: I still have no idea what's going on. I'm still trying different options though.

In the meantime, I emailed Harold Burkhart to see if he thought it was better to display the output clipped to the native range shapefile's bounding box (see option A below) or clipped to the shapefile's boundaries such that all grid cells outside the native range are masked (see option B below). Note: I'm not sure if option A also yields i,j's that are off slightly. I'm investigating that now.

Option A: clippingworked2_page_1

Option B: clippingworked2_page_2

hadinon commented 8 years ago

OK, here are a few updates:

1) Harold says his preference is Option B. 2) The i,j's got redefined with Option A so that probably wouldn't have been a solution either. 3) I noticed the i,j's start with 0,0 in the bottom left part of the original DSS historical grid of summer dryness but 0,0 is defined as top left in the new grid (option B above), which explains why only the j's are off. So, I'm trying to figure out if I can define this before writing out the new netCDF. That should fix things!

daviswx commented 8 years ago

The mask is now turned off for the Summer Dryness tool since that tool is instead being clipped to the PINEMAP region. No other tools use this mask at the moment, but it's still available if needed.

If it needs to be added for other tools, it can be added in two easy steps.

1) In the tool details PHP file, add this line:

// Whether to mask locations outside the PINEMAP region/eastern US.
$mask_pinemap_region = FALSE;

2) Right below that, add this to the map click modules section:

$map_click_modules[0] = 'getFeatureInfo_ij_masklayer.php';

Since the latest update to the clipping seems to have addressed the i,j problem, I will close this issue. Any comments about the Summer Dryness tool in particular can be added to issue #70 .