Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the sum comparison #753

Open
PhilippBuehler opened this issue Oct 25, 2017 · 10 comments
Open

Fixing the sum comparison #753

PhilippBuehler opened this issue Oct 25, 2017 · 10 comments
Labels

Comments

@PhilippBuehler
Copy link

PhilippBuehler commented Oct 25, 2017

VIC-Version:
VIC 5.0.1 and Developer version
OS and compiler:
Ubuntu + gcc
Model settings:
default

Error message:
[WARN] ../shared_image/src/vic_init.c:1235: errno: Numerical argument out of domain: Cv != 1.0 (1.000000) at grid cell 0. Exiting ...

Description
This error message shouldn't appear since the input argument are doubles, so the sum can sometimes not be exactly 1:
Eventually compare within a tolerance of 1% ?

I also have a StackOverflow question open regarding that topic:
https://stackoverflow.com/questions/46942196/sum-of-fractions-of-1-not-exactly-equally-1

@jhamman
Copy link
Member

jhamman commented Oct 27, 2017

@PhilippBuehler - please provide the requested issue information.

@PhilippBuehler
Copy link
Author

@jhamman edited it

@jhamman
Copy link
Member

jhamman commented Nov 1, 2017

@PhilippBuehler -can you run with the code on the develop branch - make sure to rebuild the code. I think we already fixed this:

https://github.com/UW-Hydro/VIC/blob/develop/vic/drivers/shared_image/src/vic_init.c#L1230-L1241

xref: #701

@PhilippBuehler
Copy link
Author

PhilippBuehler commented Nov 1, 2017

I tried with the developer branch again and the same error:

[WARN] ../shared_image/src/vic_init.c:1235: errno: Numerical argument out of domain: Cv !=  1.0 (1.000000) at grid cell 0. Exiting ...
location:
	latitude       : 35.4846
	longitude      : -97.3926
	area           : 1.1746
	frac           : 1.0000
	nveg           : 10
	global_idx     : 0
	io_idx         : 16
	local_idx      : 0

[WARN] ../shared_image/src/vic_init.c:1235: errno: None: Cv !=  1.0 (1.000000) at grid cell 1. Exiting ...
location:
	latitude       : 35.4846
	longitude      : -97.3788
	area           : 1.1746
	frac           : 1.0000
	nveg           : 8
	global_idx     : 1
	io_idx         : 17
	local_idx      : 1

The errormessage occurs for all gridcells which arent exactly 1(int). (See my StackOverflow Problem)

@jhamman
Copy link
Member

jhamman commented Nov 1, 2017

@PhilippBuehler - It seems this section of code may not be doing what we intended:

if (!assert_close_double(Cv_sum[i], 1., 0., AREA_SUM_ERROR_THRESH)) {
sprint_location(locstr, &(local_domain.locations[i]));
log_warn("Cv != 1.0 (%f) at grid cell %zd. Exiting ...\n%s",
Cv_sum[i], i, locstr);
for (j = 0; j < options.NVEGTYPES; j++) {
vidx = veg_con_map[i].vidx[j];
veg_con[i][vidx].Cv /= Cv_sum[i];
}
}
}

I'll mark this as a bug but it would be great if you can dig into this a bit more and figure out why VIC is making it into this if block.

Also, just to be clear, this is just a warning -- not an error. The model should be otherwise functioning normally despite printing this message.

@jhamman jhamman added the bug label Nov 1, 2017
@PhilippBuehler
Copy link
Author

PhilippBuehler commented Nov 3, 2017

I pushed some changes into my fork:
bf228e5

Read there about the changes. I hope I did everything right with GitHub, everything here is pretty new for me.

Philipp

@jhamman
Copy link
Member

jhamman commented Nov 6, 2017

@PhilippBuehler - you'll need to open a pull request. A general comment though, I think -1e6 is probably too permissive. See this discussion for more details: #701 (comment). I don't recall why we ended up with -1e20 vs -1e10 .

@PhilippBuehler
Copy link
Author

-1e10 is not working for me, it produces these numbers:

0.00000001012813299894 is bigger then 0.00000000010000000000
0.00000000465661287308 is bigger then 0.00000000010000000000
0.00000001973239704967 is bigger then 0.00000000010000000000
0.00000000419095158577 is bigger then 0.00000000010000000000
0.00000000605359673500 is bigger then 0.00000000010000000000
0.00000000849831849337 is bigger then 0.00000000010000000000
0.00000001792795956135 is bigger then 0.00000000010000000000
0.00000000104773789644 is bigger then 0.00000000010000000000

@jhamman
Copy link
Member

jhamman commented Nov 6, 2017

@PhilippBuehler - what dataset are you working with? My suspicion is that your Cv variable does not sum exactly to one.

@PhilippBuehler
Copy link
Author

You mean

sum up to exactly 1?

I produced my own dataset with the nlcd_2011_landcover data to get small resolution grids.
I can give you my Matlab code or my parameter netcdf file if you like.

And again reffering you to my StackOverflow problem, maybe it helps clearing things up.
https://stackoverflow.com/questions/46942196/sum-of-fractions-of-1-not-exactly-equally-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants