View on GitHub

IRAF Community Distribution

IRAF maintained by the community

Home | Installation | Packages | X11IRAF | PyRAF | Forum

How to add a suffix to image names in a procedure script ?

smp wrote on Sep 18, 2009

Hi,

I have a file which contains many image-names.

I want to add a suffix to all them.

e.g. I have a file named as "bias_file"
And it contains 3 image-names:
bias1.fits
bias2.fits
bias3.fits

Now I want image-names to be:
bias1_copy.fits
bias2_copy.fits
bias3_copy.fits

So, how will I do this inside a procedure script?

In the help, for the task FILES, an example is given:

     cl> files root.%*%y%


But how to implement this in compute mode (i.e. inside script) for a set of image-names contained inside a text file?
-----------------------------------------------------------------------------------------------------------

Actually, I am expanding the template, then pipe-ing the image-name to task FILES to add a suffix:

(Now the text file named as "bias_file" contains only one image-name, namely: bias1.fits.)

sections(bias_file, option = "root") | scan(s1)
print(s1)
files (s1//"%_copy.fits%") | scan(s2)
print(s2)


But both print statements here prints the same image-name i.e. bias1.fits

I was expecting:

s1 = bias1
s2 = bias1_copy.fits

-----------------------------------------------------------------------------------------------------------

Regards
smp

Mike Fitzpatrick wrote on Sep 18, 2009

A simpler way to add extensions is with RENAME, see Example 5 of the help page:


5. Add a ".fits" extension to all files in a directory.

cl> rename im00* fits field=extn


-Mike

smp wrote on Sep 18, 2009

Thanks.

But I want a copy of a file with different name.

i.e.
I have a file "bias_1.fits"
I want to copy this file with the name "bias_1_copy.fits" or at least by the name "bias_1.copy.fits".

i.e. at the end, I should I have original file + one more file derived from original file (with different name).

Regards
smp

Mike Fitzpatrick wrote on Sep 18, 2009

Sorry, was reading too fast before having any coffee, try


ecl> files bias*%.fits%_copy.fits%
bias1_copy.fits
bias2_copy.fits
bias3_copy.fits


-Mike

smp wrote on Sep 18, 2009

Thanks.

I will try this in compute mode (in procedure script).

(I am sorry for starting a new topic here. )

Before this, I want to know how to display a comment like

Either YES or NO options are available for this parameter.

whenever I type any string other than YES / NO as input to a hidden parameter in my own task ( a procedure script).

e.g. This is a segment of parameter list of my task:

object_filen = "@HD80606b_B_list" Give name of file containing science images
 bias_filenam = "@bias_list"    Give name of the file containing bias images
 flat_filenam = "@flat_b_list"  Give name of file containing flat images
    (BiasMthd = "none")         Type of Bias subtraction (os|osb|bias|none)
      (FltFld = "abc")           Need flat fielding?(yes|no)


Suppose I type "abc" instead of YES or NO (as shown), I should get the message quoted above.

Please tell how to do this?

Regards
smp

Last post on Sep 18, 2009