2 questions [message #26318] |
Wed, 15 August 2001 19:49  |
Bob Fugate
Messages: 18 Registered: March 2001
|
Junior Member |
|
|
I am batch processing a number of HDF files, saving output to results files.
I have a short procedure that first checks the validity of the files using
HDF_ISHDF -- just to avoid file access problems during the main processing
routines. The files are located on a server, or if old enough, on a tape
library, with only a stub left on the server. A file on tape opened by
HDF_ISHDF (or any other routine) is automatically restored from tape to the
server. The problem is, if the file is on tape, HDF_ISHDF times out before
the file gets reloaded. HDF_ISHDF fails. I could modify the check routine to
put these files in a separate list to process on the second pass once the
files are restored. I don't have a simple way (and apparently not even a
complicated way) to check on the status of these files to know whether they
are on the server or in the library.
Question: Is there a better way to handle this? For instance, is there a way
to extend the time-out period to allow the file to be restored so it can be
checked and subsequently processed? Is there a way to terminate the
HDF_ISHDF query before it times out and put this file on a list to process
in a second batch? Any suggestions greatly appreciated.
Question 2: I am using IDL on 2 platforms: MacOS and Windows NT, both
versions 5.4. On the Mac, there is a feature that lets one select any number
of lines in the editor and comment them all out in one command (and
subsequently uncomment them when needed)--- a very valuable feature for
someone like me who is not proficient at programming. I can't find this
feature in the Windows version. Am I missing it somehow? Any suggested
approaches short of saving the file under a new name and deleting lines in
that file?
Thanks in advance. This group is one reason I like IDL.
|
|
|
Re: 2 questions [message #57488 is a reply to message #26318] |
Tue, 11 December 2007 13:00   |
wgallery
Messages: 32 Registered: December 1998
|
Member |
|
|
On Dec 11, 3:00 pm, David Fanning <n...@dfanning.com> wrote:
> R.G. Stockwell writes:
>> I have never been clear on what makes a ps file be an 'eps' file,
..............
> Most EPS files, though, also contain, in addition to
> the PostScript part of the file, another part that
> allows the graphic to be "previewed" in applications.
> So, if you had created your PostScript file in IDL
> with the ENCAPSULATED and PREVIEW keywords set
> appropriately, and you include THAT file in your
> Word document, you might see more than a big
> rectangle with an X in it. If you had been living
> a pious life, you might even see something that looked
> like the graphic you intend to print.
>
> However, when you send that Word file to a PS printer,
> the graphic will use the PostScript part to render it,
> not the low-level preview part.
>
> Of course, IDL preview images suck, but I--like you--
> have never been too bothered by that. They print correctly,
> that's the main thing. :-)
>
As David F. stated, an idl-created preview to an eps file sucks.
However, you can include your own high quality preview to an eps file
which will look good both on screen and printed to a postscript
printer. Details below. Note that as of Microsoft Office 2002, Word
discards any preview supplied with an .eps file and substitutes is own
even suckier preview (see: http://support.microsoft.com/kb/290362/en-us).
My solution to this problem is to create an eps file without a preview
and convert it to a high resolution (300 dpi) .png file using
epstool. This file looks good both on screen (even in Word) and
printed. Details below.
To add a high quality (i.e., high resolution) preview to the .ps file
idl.ps:
epstool -w --dpi 300 idl.ps idl.eps
You can use epstool either on a Linux/Unix box or in Windows under
cygwin.
For epstool, see: http://pages.cs.wisc.edu/~ghost/gsview/epstool.htm
To create a high-quality .png file from an .eps file:
gs -sDEVICE=png256 -r300 -dBATCH -dNOPAUSE -sEPSCrop -q -
sOutputFile=idl.png idl.eps
For ghostscript (gs) see: http://pages.cs.wisc.edu/~ghost/doc/AFPL/index.htm
Finally, I have an idl procedure eps_to_png.pro which does the
creation of a high-quality .png file. It works on both Windows and
Linux/Unix (but requires ghostscript to be installed.) Here it is:
------------------------------------------------------------ ------------------------------
;+
;$Name: $
;$Id: eps_to_png.pro,v 1.7 2007/07/30 15:17:31 wgallery Exp $
;
; NAME:
; eps_to_png
;
; PURPOSE:
; To convert an postscript plot file (.ps or .eps) to a Portable
Network Graphics
; file (.png).
;
; CATEGORY:
; Graphics
;
; CALLING SEQUENCE:
; eps_to_png, filename, error, delete = delete, resolution =
resolution, true = true
;
;
; INPUTS:
; filename = string: fully qualified name of the postscript file.
The .png file will have
; the same base name but with .ps or .eps replaced with .png.
;
; KEYWORD PARAMETERS:
; delete: if set and spawn executes sucessfully, then delete the .eps
file
; resolution: int: resolution of the .png file, in pixels-per-inch,
default = 300
; true: if set, then the .png file is in 24 bit truecolor. Default: 8
bit color.
;
; OUTPUTS:
; error: 0: no error occured, 1: an error occured in processing
;
; PROCEDURE:
; This procedure should work on either Windows or Unix (Linix)
platforms that have the
; program ghostscript installed (program name: Windows=gswin32c.exe,
Unix=gs). It runs
; ghostscript with the proper parameters to convert the postscript
file (.ps or .eps) to
; a .png file. The resolution of the .png file is by default 300
pixels-per-inch which
; is sufficient for inclusion in Word or Powerpoint documents. For
multipage .ps files,
; each page will be sent to spearate file with a sequence number
before the .png. E.g.,
; a 3 page .ps file named foo.ps will produce foo_01.png, foo_02.png,
and foo_03.png.
;
; MODIFICATION HISTORY:
; Created:
; Oct. 31, 2006 William Gallery, AER, Inc wgallery@aer.com
; Jan. 31, 2006 William Gallery,
; Added capability of converting multipage .ps file to
sequential .png files
;-
pro eps_to_png, filename, error, delete = delete, resolution =
resolution, true = true
error = 0
;;Check that the file exists
r = file_test(filename, /read)
if r ne 1 then begin
print, 'Error: file does not exist or is not readable, file: ',
filename
error = 1
return
endif
;;Separate the file root from the extension
separate_filename_parts, filename, name = name, ext = ext, path =
path, drive = drive
if ext ne 'eps' and ext ne 'ps' then begin
print, 'Error: file does not have .eps or .ps extention, file: ',
filename
error = 1
return
endif
;;Get the absolute path: the relative path will not work on Windows
path = file_expand_path(path)
;;In Windows, file_expand_path prepends the drive so don't include it
again
case ext of
'eps': png_filename = path+path_sep()+name+'.png'
'ps': png_filename = path+path_sep()+name+'_%02d.png' ;add sequence
number
endcase
case strupcase(!version.os_family) of
'UNIX': gs_name = 'gs'
'WINDOWS': gs_name = 'gswin32c.exe'
else: begin
print, 'OS not recognized, OS: ', !version.os_family
error = 1
return
end
endcase
;;Options for the gs command. Note: capitalization is important
if n_elements(resolution) gt 0 then res = strtrim(fix(resolution), 2)
else res = '300'
if keyword_set(true) gt 0 then out_dev = 'png16m' else out_dev =
'png256'
gs_options = ['-sDEVICE='+out_dev, '-r'+res, '-dBATCH', '-dNOPAUSE ',
'-sEPSCrop ']
;;Run spawn with the /noshell option to make it run faster.
;;(Note: in this form, it hangs idl!!!????)
; cmd_ns = [gs_name, gs_options, '-sOutputFile='+png_filename,
filename]
; spawn, cmd_ns, /noshell, $
; sp_out, sp_err_out, $
; count = sp_count, exit_status = exit_status
cmd = gs_name+' '+strjoin(gs_options, ' ')+ $
' -sOutputFile='+png_filename+' '+ $
file_expand_path(filename)
case strupcase(!version.os_family) of
'UNIX': begin
spawn, cmd, sp_out, sp_err_out, $
count = sp_count, exit_status = exit_status
end
'WINDOWS': begin
spawn, cmd, sp_out, sp_err_out, $
count = sp_count, exit_status = exit_status, $
/hide
end
endcase
if exit_status ne 0 then begin
print, 'Error: from eps_to_png: exit status = ', exit_status
print, sp_out
print, sp_err_out
error = 1
return
endif
if keyword_set(delete) then file_delete, filename
return
end
|
|
|
Re: 2 questions [message #57489 is a reply to message #26318] |
Tue, 11 December 2007 12:07   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
R.G. Stockwell wrote:
> "Paul van Delst" <Paul.vanDelst@noaa.gov> wrote in message
> news:fjmoe7$rji$1@news.nems.noaa.gov...
>> Vince Hradil wrote:
>>> On Dec 11, 12:50 pm, nakisa <nakisa.noor...@gmail.com> wrote:
>>>> Hi everybody
>>>> I have some question.
>>>> 1) How can I convert the plotted figure to eps format?
>>>> 2 ) I use "trigrid " for plot a three dimensional, is it possible to
>>>> plot contour in the same plot ?
>>>> Best, nakisa
>>> 1) http://www.dfanning.com/tips/postscript_preview.html
>> To the OP,
>>
>> FWIW, I use the epstool method to convert ps to eps and include them in
>> latex documents. Works great.
>>
>>> 2) Maybe look into the T3D graphics keyword.
>
> I have never been clear on what makes a ps file be an 'eps' file,
> but I just use the idl ps output (and rename the file *.eps).
> IDL includes the bounding box statement, which seems to be
> what the request for eps is really asking for.
> I use the IDL ps files in latex, and they are accepted by
> journals as photo-ready figures.
Hi,
I Use eps so I can also stick the images in, e.g., a word doc with a preview. The reason I
use eps in latex is because the first time I tried it (I use the graphicx package) the eps
was positioned correctly, but the ps file was not. I did not investigate any further - I
just went with what worked.
cheers,
paulv
|
|
|
Re: 2 questions [message #57490 is a reply to message #26318] |
Tue, 11 December 2007 12:00   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
R.G. Stockwell writes:
> I have never been clear on what makes a ps file be an 'eps' file,
> but I just use the idl ps output (and rename the file *.eps).
> IDL includes the bounding box statement, which seems to be
> what the request for eps is really asking for.
> I use the IDL ps files in latex, and they are accepted by
> journals as photo-ready figures.
I think IDL includes the bounding box so that whatever
application you intend to include your EPS file in can
at least save the space for the graphic, even it it
can't render the PostScript itself. That is why, for
example, if you included your "renamed" file in
a Word document it would show up as a big rectangle
with an X though it and "IDL graphic" or some such
written at the top.
Most EPS files, though, also contain, in addition to
the PostScript part of the file, another part that
allows the graphic to be "previewed" in applications.
So, if you had created your PostScript file in IDL
with the ENCAPSULATED and PREVIEW keywords set
appropriately, and you include THAT file in your
Word document, you might see more than a big
rectangle with an X in it. If you had been living
a pious life, you might even see something that looked
like the graphic you intend to print.
However, when you send that Word file to a PS printer,
the graphic will use the PostScript part to render it,
not the low-level preview part.
Of course, IDL preview images suck, but I--like you--
have never been too bothered by that. They print correctly,
that's the main thing. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: 2 questions [message #57491 is a reply to message #26318] |
Tue, 11 December 2007 11:44   |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
"Paul van Delst" <Paul.vanDelst@noaa.gov> wrote in message
news:fjmoe7$rji$1@news.nems.noaa.gov...
> Vince Hradil wrote:
>> On Dec 11, 12:50 pm, nakisa <nakisa.noor...@gmail.com> wrote:
>>> Hi everybody
>>> I have some question.
>>> 1) How can I convert the plotted figure to eps format?
>>> 2 ) I use "trigrid " for plot a three dimensional, is it possible to
>>> plot contour in the same plot ?
>>> Best, nakisa
>>
>> 1) http://www.dfanning.com/tips/postscript_preview.html
>
> To the OP,
>
> FWIW, I use the epstool method to convert ps to eps and include them in
> latex documents. Works great.
>
>> 2) Maybe look into the T3D graphics keyword.
I have never been clear on what makes a ps file be an 'eps' file,
but I just use the idl ps output (and rename the file *.eps).
IDL includes the bounding box statement, which seems to be
what the request for eps is really asking for.
I use the IDL ps files in latex, and they are accepted by
journals as photo-ready figures.
Cheers,
bob
|
|
|
Re: 2 questions [message #57492 is a reply to message #26318] |
Tue, 11 December 2007 11:40   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
nakisa writes:
> 1) How can I convert the plotted figure to eps format?
You don't usually "convert" anything. You either draw
your figure to the display device, or you draw your
figure to the PostScript device. Suppose you wrote
an IDL program named DRAWPLOT to draw a graphics plot:
IDL> Drawplot, mydata
Then to draw the same plot in a PostScript file
(assuming the code is written correctly), you would
do something like this:
thisDevice = !D.Name
keywords = PSConfig(/Encapculated, _Extra=PSWindow(), Cancel=cancel)
IF ~cancel THEN BEGIN
Set_Plot, 'PS'
Device, _EXTRA=keywords
Drawplot, mydata
Device, /Close
Set_Plot, thisDevice
ENDIF
> 2 ) I use "trigrid " for plot a three dimensional, is it possible to
> plot contour in the same plot ?
If you have set up a 3D coordinate system (by typing a command like
SURFR, or SCALE3D, or even SURFACE), then you can make a CONTOUR
command use the save 3D coordinate system by setting the T3D keyword.
You will find LOTS of information about producing PostScript output
on my web page. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
|
|
Re: 2 questions [message #57576 is a reply to message #57488] |
Wed, 12 December 2007 17:12  |
R.G.Stockwell
Messages: 163 Registered: October 2004
|
Senior Member |
|
|
"Bill Gallery" <wgallery@aer.com> wrote in message
news:db33b76f-7c42-47de-9a74-5b2de78d4b3f@d27g2000prf.google groups.com...
...
> As David F. stated, an idl-created preview to an eps file sucks.
> However, you can include your own high quality preview to an eps file
> which will look good both on screen and printed to a postscript
> printer. Details below. Note that as of Microsoft Office 2002, Word
> discards any preview supplied with an .eps file and substitutes is own
> even suckier preview (see: http://support.microsoft.com/kb/290362/en-us).
>
> My solution to this problem is to create an eps file without a preview
> and convert it to a high resolution (300 dpi) .png file using
> epstool. This file looks good both on screen (even in Word) and
> printed. Details below.
thanks for all the info!
Cheers,
bob
|
|
|