drww / newhall

A Java implementation of the Newhall model for soil temperature and moisture regime determination. Given a year of monthly averages for precipitation and temperature at a location, the model will simulate the recharge and discharge of moisture through the underlying soil.
Other
5 stars 2 forks source link

PET southern hemisphere latitude correction factor #19

Open tgr1 opened 9 years ago

tgr1 commented 9 years ago

We obtained unexpected PET results using the jNSM in the southern hemisphere Original basic code was compared to current code for the southern hemisphere logic The PET results correction factor uses a linear interpolation of the degree latitude S and correction factors for each month and the input latitude The current code appears to be different

original code 625 CF=((FS(NROW%+1,I)-FS(NROW%,I))_(((RLA1%-RS(NROW%))_60!)+RLA2%))/((RS(NROW%+1)-RS(NROW%))*60!) Where RLA1% = input latitude degrees RLA2% = input latitude minutes

Current code in r311

// 625 double cf = (BASICSimulationModelConstants.fs[i - 1][nrow] - BASICSimulationModelConstants.fs[i - 1][nrow - 1])* ((dataset.getLatitudeMinutes() - BASICSimulationModelConstants.rs[nrow - 1]) * 60)/ ((BASICSimulationModelConstants.rs[nrow] - BASICSimulationModelConstants.rs[nrow - 1]) * 60);

Amended code

// 625 double cf = ((BASICSimulationModelConstants.fs[i - 1][nrow] - BASICSimulationModelConstants.fs[i - 1][nrow - 1])* (((dataset.getLatitudeDegrees() - BASICSimulationModelConstants.rs[nrow - 1]) * 60) + dataset.getLatitudeMinutes()))/ ((BASICSimulationModelConstants.rs[nrow] - BASICSimulationModelConstants.rs[nrow - 1]) * 60);

drww commented 9 years ago

Hello!

I can definitely see the omission versus the original source. Just applied the recommended changes, repeated the build, and all of the prior unit tests passed. This change is subtle enough that the uncorrected version really doesn't cause much distortion except in the specific situations identified.

Give the following JAR a spin, it's the current version of Newhall with the one amended line above, you should be able to run it with "java -jar Newhall-1.6.0-TESTBUILD-A.jar": https://s3-us-west-1.amazonaws.com/drww/Newhall-1.6.0-TESTBUILD-A.jar

If you find it works out better on some of the affected sets, I can fold this change into a new release, and increment the version counter accordingly. "1.6.1" has a good ring to it. If you can provide some datasets that demonstrate the problem (2-3 would be fine), I can also fold those into the unit test framework, to make sure this fix never regresses.