Re: FORMAT question [message #27040] |
Sun, 07 October 2001 23:52 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Paul van Delst wrote:
>
> Reimar Bauer wrote:
>>
>> Paul Manusiu wrote:
>>>
>>> Hi,
>>> Does anyone if its possible to use a function or variable as a parameter
>>> or option to FORMAT ?
>>> ;e.g. if I have
>>> print, blah, FORMAT = '(2(F6.1))'
>>> ; but I want something like this
>>> for var = 0, 10 do $
>>> print, blah[var,*], FORMAT = '(var(F6.1))'
>>>
>>> Any help please will be much appreciated
>>>
>>> Paul M.
>>
>> Dear Paul,
>>
>> this is the first time I am able to give totally the same answer
>> to someone in this newsgroup at the same day. Don't you read others
>> articles?
>
> Actually your reply doesn't directly apply to the problem he's having - i.e. a repreat
> specifier in a format statements - although your software might.
>
I agree, I have not seen this problem. The routine could be useful too
if you don't
know anything about the format of the data.
The online help with the keyword "Format codes" describes much more
formatting codes
and syntax.
Reimar
> In any case, apart from Andrew's solution, I would also try:
>
> IDL> var=2
> IDL> fmt='('+strtrim(var,2)+'(f6.1))'
> IDL> print, fmt
> (2(f6.1))
>
> to avoid the need for _another_ format when outputting var into the format string.
>
> paulv
>
> --
> Paul van Delst Religious and cultural
> CIMSS @ NOAA/NCEP purity is a fundamentalist
> Ph: (301)763-8000 x7274 fantasy
> Fax:(301)763-8545 V.S.Naipaul
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
|
|
|
Re: FORMAT question [message #27049 is a reply to message #27040] |
Fri, 05 October 2001 12:45  |
Phillip David
Messages: 36 Registered: April 1999
|
Member |
|
|
try the even simpler command:
x = findgen(10)*!pi
print, x, format='(' + strtrim(n_elements(x),2) + '(f10.6))'
This will print out all elements on a single line.
As an additional note, if you use print, x, format='((f10.6))', you'll
get each element printed on its own line, but they still all get
printed. More useful, perhaps, is the idea that you can get an
appropriate line length this way.
x = findgen(1000)*!pi
print, x, format='(10(f10.6))'
will give you 100 lines with 10 elements each on them.
You probably knew this, but there may have been some who didn't.
Phillip
Paul Manusiu wrote:
>
> Hi,
> Does anyone if its possible to use a function or variable as a parameter
> or option to FORMAT ?
> ;e.g. if I have
> print, blah, FORMAT = '(2(F6.1))'
> ; but I want something like this
> for var = 0, 10 do $
> print, blah[var,*], FORMAT = '(var(F6.1))'
>
> Any help please will be much appreciated
>
> Paul M.
|
|
|
Re: FORMAT question [message #27056 is a reply to message #27049] |
Fri, 05 October 2001 08:11  |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
Reimar Bauer wrote:
>
> Paul Manusiu wrote:
>>
>> Hi,
>> Does anyone if its possible to use a function or variable as a parameter
>> or option to FORMAT ?
>> ;e.g. if I have
>> print, blah, FORMAT = '(2(F6.1))'
>> ; but I want something like this
>> for var = 0, 10 do $
>> print, blah[var,*], FORMAT = '(var(F6.1))'
>>
>> Any help please will be much appreciated
>>
>> Paul M.
>
> Dear Paul,
>
> this is the first time I am able to give totally the same answer
> to someone in this newsgroup at the same day. Don't you read others
> articles?
Actually your reply doesn't directly apply to the problem he's having - i.e. a repreat
specifier in a format statements - although your software might.
In any case, apart from Andrew's solution, I would also try:
IDL> var=2
IDL> fmt='('+strtrim(var,2)+'(f6.1))'
IDL> print, fmt
(2(f6.1))
to avoid the need for _another_ format when outputting var into the format string.
paulv
--
Paul van Delst Religious and cultural
CIMSS @ NOAA/NCEP purity is a fundamentalist
Ph: (301)763-8000 x7274 fantasy
Fax:(301)763-8545 V.S.Naipaul
|
|
|
|
Re: FORMAT question [message #27060 is a reply to message #27057] |
Fri, 05 October 2001 05:15  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Paul Manusiu wrote:
>
> Hi,
> Does anyone if its possible to use a function or variable as a parameter
> or option to FORMAT ?
> ;e.g. if I have
> print, blah, FORMAT = '(2(F6.1))'
> ; but I want something like this
> for var = 0, 10 do $
> print, blah[var,*], FORMAT = '(var(F6.1))'
>
> Any help please will be much appreciated
>
> Paul M.
Dear Paul,
this is the first time I am able to give totally the same answer
to someone in this newsgroup at the same day. Don't you read others
articles?
we have some routines which returns the format code of a value
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/find_form.tar.gz
; EXAMPLE:
; numbers=[100,2.1345,1000.]
; print,find_form(numbers)
; F10.4
; print,find_form(numbers,/reduce_accuracy)
; F10.2
; print,find_form(-40010138.D)
; I9
; print,find_form(-40010138.D,/force)
; F10.0
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/number_format.tar.gz
For further routines and licensing please have a look at
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
|
|
|
Re: FORMAT question [message #27062 is a reply to message #27060] |
Fri, 05 October 2001 03:55  |
A. D. & J.C. Cool
Messages: 16 Registered: February 2000
|
Junior Member |
|
|
Paul Manusiu wrote:
> Hi,
> Does anyone if its possible to use a function or variable as a parameter
> or option to FORMAT ?
> ;e.g. if I have
> print, blah, FORMAT = '(2(F6.1))'
> ; but I want something like this
> for var = 0, 10 do $
> print, blah[var,*], FORMAT = '(var(F6.1))'
>
> Any help please will be much appreciated
>
> Paul M.
Hi Paul,
Try building up your format string :-
> IDL> var = 2
> IDL> format_str='('+ string(var,form='(i2)') + '(f6.1))'
> IDL> print,format_str
> ( 2(f6.1))
> IDL> y=[1254.643,643.804]
> IDL> print,y,format=format_str
> 1254.6 643.8
>
There's probably a kosher way of doing this, but hey, it works...
Andrew Cool
|
|
|