[GRASS-dev] scientific notation in r.mapcalc ?
Hi, I just stumbled upon this while running a large model, and noticed that I couldn't easily find an answer: IIUC r.mapcalc does not support scientific notation of floating point numbers (i.e. 2.54e-05 instead of 0.254). Is that correct ? How difficult would it be to implement the support of such notation ? Moritz ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev
Re: [GRASS-dev] scientific notation in r.mapcalc ?
On Thu, Jan 19, 2017 at 12:10 PM, Moritz Lennert wrote: > Hi, > > I just stumbled upon this while running a large model, and noticed that I > couldn't easily find an answer: > > IIUC r.mapcalc does not support scientific notation of floating point > numbers (i.e. 2.54e-05 instead of 0.254). Is that correct ? > > How difficult would it be to implement the support of such notation ? We just stumbled over the same issue... would be nice to have. Markus > Moritz > ___ > grass-dev mailing list > grass-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/grass-dev -- Markus Neteler, PhD http://www.mundialis.de - free data with free software http://grass.osgeo.org http://courses.neteler.org/blog ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev
Re: [GRASS-dev] scientific notation in r.mapcalc ?
Markus Neteler wrote: > > I just stumbled upon this while running a large model, and noticed that I > > couldn't easily find an answer: > > > > IIUC r.mapcalc does not support scientific notation of floating point > > numbers (i.e. 2.54e-05 instead of 0.254). Is that correct ? > > > > How difficult would it be to implement the support of such notation ? > > We just stumbled over the same issue... would be nice to have. It works here: $ r.mapcalc "foo = 2.54e-05" $ r.info -r foo min=2.54e-05 max=2.54e-05 $ g.version -gr version=7.3.svn date=2016 revision=r70088 build_date=2017-06-16 build_platform=x86_64-pc-linux-gnu build_off_t_size=8 libgis_revision=70829 libgis_date="2017-04-04 08:43:02 +0100 (Tue, 04 Apr 2017) " mapcalc.l specifically recognises exponential notation: I [0-9]+ E [eE][-+]?[0-9]+ %% {I}"."{I}?{E}? | "."{I}{E}? { yylval.fval = atof(yytext); return DOUBLE; } atof() is specified as: 7.20.1.1 The atof function ... [#2] The atof function converts the initial portion of the string pointed to by nptr to double representation. Except for the behavior on error, it is equivalent to strtod(nptr, (char **)NULL) and strtod() as 7.20.1.3 The strtod, strtof, and strtold functions ... [#3] The expected form of the subject sequence is an optional plus or minus sign, then one of the following: -- a nonempty sequence of decimal digits optionally containing a decimal-point character, then an optional exponent part as defined in 6.4.4.2; I note that any locale-specific varations are supposed to be in addition to the format used by the "C" locale, so even if LC_NUMERIC gets set (and it shouldn't), that shouldn't affect it. Is this issue a wxGUI thing? -- Glynn Clements ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev
Re: [GRASS-dev] scientific notation in r.mapcalc ?
Hi Glynn ! On 16/06/17 02:35, Glynn Clements wrote: Markus Neteler wrote: I just stumbled upon this while running a large model, and noticed that I couldn't easily find an answer: IIUC r.mapcalc does not support scientific notation of floating point numbers (i.e. 2.54e-05 instead of 0.254). Is that correct ? How difficult would it be to implement the support of such notation ? We just stumbled over the same issue... would be nice to have. It works here: $ r.mapcalc "foo = 2.54e-05" $ r.info -r foo min=2.54e-05 max=2.54e-05 I can confirm that this works here as well. I have to admit that I don't remember the details, but it was in the context of a python script, so maybe it was something in the script. And I can't remember what solution I found at the time. It also works in python: import grass.script as g a = 2.54e-11 mce = "test = %e" % a g.run_command('r.mapcalc', expre=mce, overwrite=True) g.parse_command('r.info', flags='r', map_='test') {u'max': u'2.54e-11', u'min': u'2.54e-11'} Markus, what was your recent issue ? Maybe that will ring a bell for me... [...] Is this issue a wxGUI thing? I wasn't confronted with it using the GUI, but running a script, AFAIR. Moritz ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev
Re: [GRASS-dev] scientific notation in r.mapcalc ?
On Jun 16, 2017 5:41 PM, "Moritz Lennert" wrote: ... > Markus, what was your recent issue ? Maybe that will ring a bell for me... I think we were on a system with Italian locale. I will ask if it was happening when using the GUI (likely yes). Markus ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev
Re: [GRASS-dev] scientific notation in r.mapcalc ?
On Fri, Jun 16, 2017 at 5:56 PM, Markus Neteler wrote: > > On Jun 16, 2017 5:41 PM, "Moritz Lennert" wrote: > > ... > > Markus, what was your recent issue ? Maybe that will ring a bell for me... > > I think we were on a system with Italian locale. I will ask if it was happening when using the GUI (likely yes). this works: r.mapcalc "foo = 2.0e-05" r.mapcalc "foo = 2.e-05" this does not work: r.mapcalc "foo = 2e-05" i.e. the number before 'e' must be a floating point number, otherwise the parser looks for the raster '2e'. I guess this makes sense, maybe this needs mentioning in the manual. Markus M > > Markus > > > ___ > grass-dev mailing list > grass-dev@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/grass-dev ___ grass-dev mailing list grass-dev@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/grass-dev