comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: How to plot multiple charts and ho to round float to specific precision?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: How to plot multiple charts and ho to round float to specific precision? [message #44853] Wed, 27 July 2005 08:18 Go to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
Ben Panter wrote:
> liko2@o2.pl wrote:
>> 2. How to round float eg. 23,45654 to 23,46?
>
> I think you mean 23.45654 to 23.46?

Totally off-topic with apologies in advance, but I'm feeling a bit slow today...

I believe in some European countries the decimal point character is "," I think the 1000's
separator is "." as well (but not sure). So 20.364,475936 in these cases is equivalent to the US
20,364.475936. From Wikipedia:

------------
In France the dot was already in use in printing to make Roman numerals more readable, so the comma
was chosen. Many other countries also chose the comma is used to mark the decimal units position. It
has been made standard by the ISO for international blueprints.

English-speaking countries, however, took the comma to separate sequences of three digits. In the
US, a period (.), which is called a stop in some other such countries, was the standard.

Examples of use:

* In France, the Netherlands, and much of Latin Europe: 1 234 567,89
* In Germany, Romania and much of Europe: 1 234 567,89 or 1.234.567,89 (in handwriting you may
also come across 1�234�567,89)
* In Switzerland (mainly German-speaking Switzerland): 1'234'567,89
* In the United Kingdom and United States: 1,234,567.89 or 1,234,567�89; the latter is more
commonly found in older, and especially handwritten, documents nowadays; many UK schools now teach
the SI style, which has become official in Australia.
* SI style: 1 234 567.89 (dot countries) or 1 234 567,89 (comma countries)

Dot countries

Countries where a dot is used to mark the radix point include:

Australia, Botswana, Canada (English-speaking), China, Costa Rica, Dominican Republic, El
Salvador, Guatemala, Honduras, Hong Kong of the People's Republic of China, India, Ireland, Israel,
Japan, Korea (both North and South), Malaysia, Mexico, Nicaragua, New Zealand, Panama, Philippines,
Saudi Arabia, Singapore, Taiwan, Thailand, United Kingdom, United States (including insular area of
Puerto Rico),

Comma countries

Countries where a comma is used to mark the radix point include:

Albania, Andorra, Argentina, Austria, Belarus, Belgium, Bolivia, Brazil, Bulgaria, Canada
(French-speaking), Croatia, Cuba, Chile, Colombia, Czech Republic, Denmark, Ecuador, Estonia,
Faroes, Finland, France, Germany, Greece, Greenland, Hungary, Indonesia, Iceland, Italy, Latvia,
Lithuania, Luxembourg, Macedonia, Moldova, Netherlands, Norway, Paraguay, Peru, Poland, Portugal,
Romania, Russia, Serbia, Slovakia, Slovenia, Spain, South Africa, Sweden, Switzerland, Ukraine,
Uruguay, Venezuela, Zimbabwe
---------------

Looks like the Canadians have a hard time of it. :o)

That's gotta be hard to get used to. I still have trouble with dates here in the US when the day is
< 12. In Australia 04/07/2005 is the 4th of July. In the US it's the 7th of April.

Anyway..... The world is a funny (peculiar) place.

cheers,

paulv

--
Paul van Delst
CIMSS @ NOAA/NCEP/EMC
Re: How to plot multiple charts and ho to round float to specific precision? [message #44854 is a reply to message #44853] Wed, 27 July 2005 08:02 Go to previous messageGo to next message
K. Bowman is currently offline  K. Bowman
Messages: 330
Registered: May 2000
Senior Member
In article <1122472093.151103.58110@g14g2000cwa.googlegroups.com>,
"liko2@o2.pl" <liko2k@gmail.com> wrote:

> Hi :)
>
> 1. How to plot multiple plots (eg 8-10 on one page of A4) but not using
> multiplot?

!P.REGION

or

!P.POSITION

> 2. How to round float eg. 23,45654 to 23,46?
>
> THX for answer :)

IDL> x = 23.45654
IDL> PRINT, ROUND(100.0*x)/100.0
23.4600

Ken Bowman
Re: How to plot multiple charts and ho to round float to specific precision? [message #44856 is a reply to message #44854] Wed, 27 July 2005 08:02 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
liko2@o2.pl writes:

> 1. How to plot multiple plots (eg 8-10 on one page of A4) but not using
> multiplot?

Using the keywords POSITION and NOERASE with the PLOT command
allows you to plot as many plots as you like, wherever you like.

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: How to plot multiple charts and ho to round float to specific precision? [message #44857 is a reply to message #44856] Wed, 27 July 2005 07:36 Go to previous messageGo to next message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
liko2@o2.pl wrote:
> Hi :)
>
> 1. How to plot multiple plots (eg 8-10 on one page of A4) but not using
> multiplot?

Very simply,

!p.multi=[0,3,4]

or is that what you mean by multiplot?

Otherwise investigate the position keyword and have a look at

http://www.dfanning.com/documents/tips.html

Under "Graphics Display Tips (2D)"

> 2. How to round float eg. 23,45654 to 23,46?

I think you mean 23.35654 to 23.46? In which case you can use something
like the ceil/floor/round functions. For the example you gave, you need
to do something like

num=23.45654
ans=round(100.*num)/100.

HTH,

Ben
Re: How to plot multiple charts and ho to round float to specific precision? [message #44963 is a reply to message #44857] Thu, 28 July 2005 12:29 Go to previous message
Patrick Broos is currently offline  Patrick Broos
Messages: 27
Registered: December 1996
Junior Member
I was faced with the general case of this problem, i.e. where you don't
know the magnitude of the number but you want to limit it to a certain
number of significant digits, and was moved to write the routine below.
There may be a much easier way. :)

Cheers,
Patrick Broos

;+
;=========================================================== =============
;;;
;;; FILE NAME: @(#)limit_precision.pro 8.5
;;;
;;; DESCRIPTION: This routine converts a real number to a string with
the
;;; specified number of significant digits.
;;;
;;; AUTHOR: Pat Broos (patb@astro.psu.edu)
;;; Scott Koch (tsk@astro.psu.edu)
;;; Copyright (C) 1996, Pennsylvania State University
;;;-
;=========================================================== =============
FUNCTION limit_precision, value, sig_digits

if (value EQ 0) then begin
return, '0.0'
endif


;; Calculate an increment to add or subtract to value.
log_value = alog10( abs(value) )

increment = 10.0D^(ceil( log_value ) - sig_digits)


;; Determine whether we want to add to value (round UP) or
;; subtract from value (round DOWN) in order to achieve the
;; result that ROUND() would do if the significant digits
;; were shifted to the integer part of the number.
shifted_value = value/increment
round_up = (shifted_value LT round(shifted_value))

;; Adjust the value by increment until the desired condition is met.
fmt = string( sig_digits, f='("(G20.",I0,")")' )

done = 0
steps = 0
while (NOT done) do begin
if (round_up) then begin
rounded_string = string( value + steps*increment, f=fmt )
done = (value LE float( rounded_string ))
endif else begin
rounded_string = string( value - steps*increment, f=fmt )
done = (value GE float( rounded_string ))
endelse

steps = steps + 1
if (steps GE 100) then message, 'Loop failed to converge.'
endwhile

return, strcompress( rounded_string, /REMOVE_ALL )
end
Re: How to plot multiple charts and ho to round float to specific precision? [message #44977 is a reply to message #44854] Wed, 27 July 2005 23:58 Go to previous message
liko2@o2.pl is currently offline  liko2@o2.pl
Messages: 15
Registered: July 2005
Junior Member
No, this does only the rounding and output has still 4 digits after
coma...I need to have only two digits after coma (eg. 23.46 not 23.4600)
Re: How to plot multiple charts and ho to round float to specific precision? [message #44987 is a reply to message #44853] Wed, 27 July 2005 13:54 Go to previous message
Ben Panter is currently offline  Ben Panter
Messages: 102
Registered: July 2003
Senior Member
Paul Van Delst wrote:
> Ben Panter wrote:
>
>> liko2@o2.pl wrote:
>
>>> 2. How to round float eg. 23,45654 to 23,46?
>
>>
>> I think you mean 23.45654 to 23.46?
>
>
> Totally off-topic with apologies in advance, but I'm feeling a bit slow
> today...

Midweek blues. It hits us all...

> I believe in some European countries the decimal point character is ","
> I think the 1000's separator is "." as well (but not sure). So
> 20.364,475936 in these cases is equivalent to the US 20,364.475936.

Certainly right here in Germany - coming from the UK, commas for dots
confused me for a while! I should have been a little softer in my reply
- I was trying to say "if this is what you mean I have an answer, if
it's not you're still stuck".

As far as I know the IDL syntax is always . to seperate the whole
numbers from the bits of numbers - is there a way to write location
specific code?

Ben
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Text widget error checking
Next Topic: Re: Text widget error checking

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:26:14 PDT 2025

Total time taken to generate the page: 0.00715 seconds