[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Harry Potter Learns a Spell



Tom,

This was a special case. It worked because "bias" and "dark"
just happen to have the same number of letters.  Changing
"dark" to "program" would have made a big mess. Unless you
thought to change "dark   " to  "program". FITS is not
line oriented.  It uses fixed length records.

There is a very small chance that some pixels might get
changed. If you have 4000 images then that's 14E9 pixels
or 4E9 groups of four pixels.  Seeing as there is a 1 in 
2^32 = 4E9 chance that any group of four pixels would be
"bias" one could be expected in 1000 frames. Not likely
as 1) I'll bet you did not change 1000 frames. and 2) the
data are not random.

Make the strings longer and the chance goes to near zero

try s/IMTYPE =    bias   /IMTYPE =    dark   /g

or leave off the "g" and it goes to zero as then only
the first "bias" seen in each line will get changed.


--- Tom Droege <tdroege2@earthlink.net> wrote:
> Harry asked the great wizard Mike Sallman "How can I change my bias
> files 
> to dark?"
> 
> The wizard answered:  "perl -p -i -e 's/bias/dark/g' 
> /whatever/directory/*.fits"
> 
> Moving to the right directory Harry fearlessly typed:
> 
> perl -p -i -e 's/bias/dark/g' *.fits
> 
> A small "pop" was heard, and Harry took out his DS9 wand and saw that
> the 
> change was successful.
> 
> Harry noticed that the options spell "pie" so he went to the fridge
> and cut 
> himself a piece.
> 
> Flushed with success, Harry moved to the flat file directory and
> typed:
> 
> perl -p -i -e "s/flat/object/g' *.fits
> 
> A dull thud was heard.  DS9 could no longer read the .fits files.
> 
> Donning his global edit protection cloak, Harry typed:
> 
> perl -p -i -e "s/object/flat/g' *.fits
> 
> Wonder of wonders, everything was back to normal.
> 
> Now Harry tried:
> 
> perl -p -i -e "s/flat   /object  /g' *.fits
> 
> A pleasant pop revealed that the correct change had been made, and
> the 
> files were now all labeled 'object   '
> 
> OK, I think it was Arthur Clarke who said "A sufficiently advanced 
> civilization is indistinguishable from magic."  This looks like magic
> to me.
> 
> BTW, what is to keep flat in the above from matching up with noise
> and 
> changing some of the data bits?  Does the above somehow know to just
> look 
> at the ascii text?
> 
> Tom Droege
> 
> 
> 
> At 06:29 PM 3/5/02 -0600, you wrote:
> >Tom,
> >
> >Try this (if you have Perl installed):
> >perl -p -i -e 's/bias/dark/g' /whatever/directory/*.fits
> >
> >This will replace all occurrences of bias in each .fits file in the
> >directory.
> >
> >Mike
> >
> >Tom Droege wrote:
> > >
> > > Those of you that have actually worked on DS20 should be able to
> handle
> > > this one.
> > >
> > > As you know, the dark files are incorrectly labeled "bias" in the
> fits
> > > headers.  How can I do a global edit on a directory of .fits
> files to
> > > change the "bias" to "dark"?  (If worst comes to worst, I will
> just go take
> > > a new set of darks, but it seems like it will be useful to know
> how to do
> > > this.)
> > >
> 
> 


=====
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!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/