[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: H*e*l*p Needed
Tom is learning perl, and he wants to work with FITS files, so I suggest
what I'm familar with. Your suggestion is what you are familar with. They
both work, and neither requires writing much software (maybe none for yours,
maybe 10 lines of perl for mine).
With CFITSIO.pm, you can read all key/value pairs like this:
( $file_hash{ $file }, $status ) = CFITSIO::fits_read_header( $file );
And then, check for the existance of the field you want to modify:
exists $file_hash{ $file }->{ CRVAL2 }
if it exists, you then write the value:
my $fptr = CFITSIO::open_file( $file, CFITSIO::READWRITE, $status );
$fptr->update_key_flt( 'CRVAL2', $new_value, undef, $status ); #not sure of
the exact syntax here
$fptr->close_file( $status );
And that's about the entire script...
Does hedit install outside of IRAF, or with FTOOLS? If not, I'd not
recommend installing IRAF for that purpose. And if downloading FTOOLS, grab
CFITSIO at the same time and build away.
I use FTOOLS for some stuff, and write my own scripts, which duplicate some
of FTOOLS capabilities, because it's easy and accomplishes what I want in a
more succinct way.
Cheers,
Rob
> -----Original Message-----
> From: Chris Albertson [mailto:chrisalbertson90278@yahoo.com]
> Sent: Wednesday, June 05, 2002 12:10 PM
> To: Creager, Robert S; 'Tass Mailing List'
> Subject: RE: H*e*l*p Needed
>
>
> Rob,
>
> What Tom needs to do is so simple he could use a search/replace
> function in a standard text editor if the editor allowed files
> without line terminators. Perl's 's/foo/goo/g' does just
> that. For more complex FITS hacking I'd use IRAF's "hedit".
>
> See
> http://iraf.noao.edu/scripts/irafhelp?hedit
>
> the command
> hedit *.fits CRREF1 1000
> would set CRREF1 to 1000 in all files. More example are in the
> above URL. If you are going to write software time is best
> spent writing stuff that does not already exist.
>
> Lacking a working
> IRAF installation I'd go for getting "FTOOLS" from
> http://heasarc.gsfc.nasa.gov/lheasoft/ftools/
>
>
>
> --- "Creager, Robert S" <CreagRS@LOUISVILLE.STORTEK.COM> wrote:
> >
> > Tom,
> >
> > I'd be happy to help you, and send you some code. But, you
> will have
> > to
> > install CFITSIO first
> > (http://heasarc.gsfc.nasa.gov/docs/software/fitsio/fitsio.html).
> > Then
> > preferablly, you would also install CFITSIO.pm
> > (http://search.cpan.org/search?mode=module&query=CFITSIO).
> >
> > Then I can easily help you write C or Perl code which will do what
> > you want.
> >
> > Cheers,
> > Rob
> >
> > > -----Original Message-----
> > > From: Tom Droege [mailto:tdroege2@earthlink.net]
> > > Sent: Wednesday, June 05, 2002 9:34 AM
> > > To: tass@listserv.wwa.com
> > > Subject: H*e*l*p Needed
> > >
> > >
> > > I keep forgetting that the server won't let you use certain
> > > words in the
> > > subject line. I don't see why. It is a pain.
> > >
> > > I have a bunch of data where I wrote the wrong values into CRVAL1
> > and
> > > CRVAL2. I need to do a global edit on the files.
> > >
> > > OK, I have learned some things about perl and shell scripts.
> > > So I can
> > > march the files through a process.
> > >
> > > Last time I needed to do this, perl -p -i -e 's/foo/goo/g'
> > > *.fits did the job. This is because I needed to change
> > > one specific
> > > thing to another specific thing. Now I need to change CRVALs
> > > which may
> > > have any value to a specific value. OK this is no doubt 1st
> > > grade perl but
> > > I am still in kindergarten. Someone who knows will save me
> > > spending a
> > > couple of days trying to decode sequences like ./*\a@\n&$/
> > > which seem to
> > > make perl programmers very proud when they write them.
> > >
> > > Tom Droege
> > >
> > >
> >
>
>
>
> =====
> Chris Albertson
> Home: 310-376-1029 chrisalbertson90278@yahoo.com
> Cell: 310-990-7550
> Office: 310-336-5189 Christopher.J.Albertson@aero.org
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! - Official partner of 2002 FIFA World Cup
> http://fifaworldcup.yahoo.com
>