USEPA / EPATADA

This R package can be used to compile and evaluate Water Quality Portal (WQP) data for samples collected from surface water monitoring sites on streams and lakes. It can be used to create applications that support water quality programs and help states, tribes, and other stakeholders efficiently analyze the data.
https://usepa.github.io/EPATADA/
Creative Commons Zero v1.0 Universal
40 stars 18 forks source link

ft, m, in unit conversions not working #517

Closed cristinamullin closed 2 weeks ago

cristinamullin commented 2 months ago

Describe the bug

TADA_ConvertResultUnits was not converting correctly from m, ft, or in to target of in. Ideally, the target for all of these would be m. I am not sure where the IN target or conversion factors are coming from.

I think this is coming from the WQX unit domain, but what I am seeing in WQXweb vs. the domain table (https://cdx.epa.gov/wqx/download/DomainValues/MeasureUnit.CSV) vs. the TADA WQXunitref are not consistent. Need more time to troubleshoot.

To Reproduce

Code to reproduce the behavior:

test <- TADA_DataRetrieval(
  startDate = "2020-01-01",
  endDate = "null",
  countrycode = "null",
  countycode = "null",
  huc = "null",
  siteid = "null",
  siteType = "null",
  characteristicName = "Depth, bottom",
  characteristicType = "null",
  sampleMedia = "null",
  statecode = "null",
  organization = "null",
  project = "null",
  providers = "null",
  applyautoclean = FALSE
)

test2 <- TADA_CreateUnitRef(test)

test3 <- TADA_ConvertResultUnits(test)

Screenshots

image

Additional context

Bug fixes should include all the following work:

hillarymarler commented 2 months ago

I am wrapping up some unit conversion work related to ref = "wqx". Do you want me to take a look at the length unit conversions too?

wokenny13 commented 2 months ago

The TADA.WQXUnitConversionFactor are all 0.0254 in the screenshot example that Cristina shared, which doesn't seem right.

I am looking at the WQXUnitRef.csv and it seems like that is where that 0.0254 is coming from? Also, the last changed date was recent at 3/26/2024.

image

Should the target.unit be in 'm'? Should this be brought up to WQX/WQP team at all? There doesn't seem to be a 'm' Target.Unit in WQXUnitRef at all, only in 'in'.

wokenny13 commented 2 months ago

image

Should these 3 rows in the WQXUnitRef be corrected to the values shown in the last column here?

wokenny13 commented 2 months ago

image

Should these 3 rows in the WQXUnitRef be corrected to the values shown in the last column here?

I believe these conversion factors would be correct if the Target.Unit for these 3 rows were changed to 'm'