Re: reading header and manipulating according to the header information [message #70929] |
Fri, 21 May 2010 12:37 |
sid
Messages: 50 Registered: January 1995
|
Member |
|
|
On May 16, 9:13 pm, Gray <grayliketheco...@gmail.com> wrote:
> On May 16, 10:31 am, sid <gunvicsi...@gmail.com> wrote:
>
>
>
>> On May 15, 9:21 pm, Craig Markwardt <craig.markwa...@gmail.com> wrote:
>
>>> On May 15, 12:02 pm, Craig Markwardt <craig.markwa...@gmail.com>
>>> wrote:
>
>>>> On May 15, 10:21 am, sid <gunvicsi...@gmail.com> wrote:> Hi,
>>>> > Since I am using huge data of several years, different kind of
>>>> > ccds are used on different days. I need to trim the data to a size
>>>> > which depends on ccd size, is there any method to read the header
>>>> > information and take the ccd size from there and then to proceed
>>>> > further, instead of giving the ccd size manually. Because it is really
>>>> > very tedious to check for the ccd size each time and then to proceed.
>>>> > Please help out.
>>>> > For example,
>>>> > in one of my data the ccd size that is 1K by 1k is given in header as,
>
>>>> ...
>
>>>> Anything you can do "manually," you can do in a program. The hard
>>>> part is usually to make it robust.
>
>>>> Based on the headers you provided, it looks like you have FITS image
>>>> files. If you don't already have it, get the IDL Astronomy Library.
>>>> It has many routines for reading FITS images and tables. The easiest
>>>> one to use is MRDFITS(). MRDFITS() returns the image array which you
>>>> can query using SIZE() and then trim as needed.
>
>>>> Simple example:
>>>> filename = 'myfile.fits'
>>>> img = mrdfits(filename) ;; Read image
>>>> sz = size(img, /dim) ;; Determine size of image
>>>> szx = sz(0) ;; Number of columns
>>>> szy = sz(1) ;; Number of rows
>>>> img = img( (0+2):(szx-3) , (0+2):(szy-3) ) ;; Remove outermost two
>>>> rows and columns
>
>>> Oh, and if you need other header keywords, then you need to read the
>>> header with a slightly different call to MRDFITS().
>>> img = mrdfits(filename,0,header)
>>> and then retrieve the keyword KEYNAME with FXPAR()
>>> value = fxpar(header, keyname)
>
>>> Craig
>
>> Thank you this works now i could able to read the size of ccd as a
>> variable.
>> In my data header I have a line like the one below,
>
>> COMMENT = 090222 Lat=40N exp=50s seeing 3",
>
>> in this line I need to read the lat=40N that is the value 40 as a idl
>> variable which I need use for further analysis,
>> but if I do the same process like,img = mrdfits(filename,0,header) and
>> value = fxpar(header, comment),
>> then it prints the whole sentence '090222 Lat=40N exp=50s seeing
>> 3"' .
>> So can anyone suggest is there any way to read only the desired part
>> of the string.
>
>> regards
>> sid
>
> STRSPLIT will split the comment into multiple elements, then
> WHERE(STREGEX(/Boolean)) will tell you which one you want, then GETTOK
> or STRSPLIT will extract the value.
Thank you everyone, i could do the job with
strsplit(variable,'string',/extract)
regards
sid
|
|
|
Re: reading header and manipulating according to the header information [message #70993 is a reply to message #70929] |
Sun, 16 May 2010 09:13  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On May 16, 10:31 am, sid <gunvicsi...@gmail.com> wrote:
> On May 15, 9:21 pm, Craig Markwardt <craig.markwa...@gmail.com> wrote:
>
>
>
>
>
>> On May 15, 12:02 pm, Craig Markwardt <craig.markwa...@gmail.com>
>> wrote:
>
>>> On May 15, 10:21 am, sid <gunvicsi...@gmail.com> wrote:> Hi,
>>>> Since I am using huge data of several years, different kind of
>>>> ccds are used on different days. I need to trim the data to a size
>>>> which depends on ccd size, is there any method to read the header
>>>> information and take the ccd size from there and then to proceed
>>>> further, instead of giving the ccd size manually. Because it is really
>>>> very tedious to check for the ccd size each time and then to proceed.
>>>> Please help out.
>>>> For example,
>>>> in one of my data the ccd size that is 1K by 1k is given in header as,
>
>>> ...
>
>>> Anything you can do "manually," you can do in a program. The hard
>>> part is usually to make it robust.
>
>>> Based on the headers you provided, it looks like you have FITS image
>>> files. If you don't already have it, get the IDL Astronomy Library.
>>> It has many routines for reading FITS images and tables. The easiest
>>> one to use is MRDFITS(). MRDFITS() returns the image array which you
>>> can query using SIZE() and then trim as needed.
>
>>> Simple example:
>>> filename = 'myfile.fits'
>>> img = mrdfits(filename) ;; Read image
>>> sz = size(img, /dim) ;; Determine size of image
>>> szx = sz(0) ;; Number of columns
>>> szy = sz(1) ;; Number of rows
>>> img = img( (0+2):(szx-3) , (0+2):(szy-3) ) ;; Remove outermost two
>>> rows and columns
>
>> Oh, and if you need other header keywords, then you need to read the
>> header with a slightly different call to MRDFITS().
>> img = mrdfits(filename,0,header)
>> and then retrieve the keyword KEYNAME with FXPAR()
>> value = fxpar(header, keyname)
>
>> Craig
>
> Thank you this works now i could able to read the size of ccd as a
> variable.
> In my data header I have a line like the one below,
>
> COMMENT = 090222 Lat=40N exp=50s seeing 3",
>
> in this line I need to read the lat=40N that is the value 40 as a idl
> variable which I need use for further analysis,
> but if I do the same process like,img = mrdfits(filename,0,header) and
> value = fxpar(header, comment),
> then it prints the whole sentence '090222 Lat=40N exp=50s seeing
> 3"' .
> So can anyone suggest is there any way to read only the desired part
> of the string.
>
> regards
> sid
STRSPLIT will split the comment into multiple elements, then
WHERE(STREGEX(/Boolean)) will tell you which one you want, then GETTOK
or STRSPLIT will extract the value.
|
|
|
Re: reading header and manipulating according to the header information [message #70994 is a reply to message #70993] |
Sun, 16 May 2010 07:31  |
sid
Messages: 50 Registered: January 1995
|
Member |
|
|
On May 15, 9:21 pm, Craig Markwardt <craig.markwa...@gmail.com> wrote:
> On May 15, 12:02 pm, Craig Markwardt <craig.markwa...@gmail.com>
> wrote:
>
>
>
>> On May 15, 10:21 am, sid <gunvicsi...@gmail.com> wrote:> Hi,
>>> Since I am using huge data of several years, different kind of
>>> ccds are used on different days. I need to trim the data to a size
>>> which depends on ccd size, is there any method to read the header
>>> information and take the ccd size from there and then to proceed
>>> further, instead of giving the ccd size manually. Because it is really
>>> very tedious to check for the ccd size each time and then to proceed.
>>> Please help out.
>>> For example,
>>> in one of my data the ccd size that is 1K by 1k is given in header as,
>
>> ...
>
>> Anything you can do "manually," you can do in a program. The hard
>> part is usually to make it robust.
>
>> Based on the headers you provided, it looks like you have FITS image
>> files. If you don't already have it, get the IDL Astronomy Library.
>> It has many routines for reading FITS images and tables. The easiest
>> one to use is MRDFITS(). MRDFITS() returns the image array which you
>> can query using SIZE() and then trim as needed.
>
>> Simple example:
>> filename = 'myfile.fits'
>> img = mrdfits(filename) ;; Read image
>> sz = size(img, /dim) ;; Determine size of image
>> szx = sz(0) ;; Number of columns
>> szy = sz(1) ;; Number of rows
>> img = img( (0+2):(szx-3) , (0+2):(szy-3) ) ;; Remove outermost two
>> rows and columns
>
> Oh, and if you need other header keywords, then you need to read the
> header with a slightly different call to MRDFITS().
> img = mrdfits(filename,0,header)
> and then retrieve the keyword KEYNAME with FXPAR()
> value = fxpar(header, keyname)
>
> Craig
Thank you this works now i could able to read the size of ccd as a
variable.
In my data header I have a line like the one below,
COMMENT = 090222 Lat=40N exp=50s seeing 3",
in this line I need to read the lat=40N that is the value 40 as a idl
variable which I need use for further analysis,
but if I do the same process like,img = mrdfits(filename,0,header) and
value = fxpar(header, comment),
then it prints the whole sentence '090222 Lat=40N exp=50s seeing
3"' .
So can anyone suggest is there any way to read only the desired part
of the string.
regards
sid
|
|
|
|
Re: reading header and manipulating according to the header information [message #71005 is a reply to message #71003] |
Sat, 15 May 2010 09:21  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On May 15, 12:02 pm, Craig Markwardt <craig.markwa...@gmail.com>
wrote:
> On May 15, 10:21 am, sid <gunvicsi...@gmail.com> wrote:> Hi,
>> Since I am using huge data of several years, different kind of
>> ccds are used on different days. I need to trim the data to a size
>> which depends on ccd size, is there any method to read the header
>> information and take the ccd size from there and then to proceed
>> further, instead of giving the ccd size manually. Because it is really
>> very tedious to check for the ccd size each time and then to proceed.
>> Please help out.
>> For example,
>> in one of my data the ccd size that is 1K by 1k is given in header as,
>
> ...
>
> Anything you can do "manually," you can do in a program. The hard
> part is usually to make it robust.
>
> Based on the headers you provided, it looks like you have FITS image
> files. If you don't already have it, get the IDL Astronomy Library.
> It has many routines for reading FITS images and tables. The easiest
> one to use is MRDFITS(). MRDFITS() returns the image array which you
> can query using SIZE() and then trim as needed.
>
> Simple example:
> filename = 'myfile.fits'
> img = mrdfits(filename) ;; Read image
> sz = size(img, /dim) ;; Determine size of image
> szx = sz(0) ;; Number of columns
> szy = sz(1) ;; Number of rows
> img = img( (0+2):(szx-3) , (0+2):(szy-3) ) ;; Remove outermost two
> rows and columns
Oh, and if you need other header keywords, then you need to read the
header with a slightly different call to MRDFITS().
img = mrdfits(filename,0,header)
and then retrieve the keyword KEYNAME with FXPAR()
value = fxpar(header, keyname)
Craig
|
|
|
Re: reading header and manipulating according to the header information [message #71006 is a reply to message #71005] |
Sat, 15 May 2010 09:02  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On May 15, 10:21 am, sid <gunvicsi...@gmail.com> wrote:
> Hi,
> Since I am using huge data of several years, different kind of
> ccds are used on different days. I need to trim the data to a size
> which depends on ccd size, is there any method to read the header
> information and take the ccd size from there and then to proceed
> further, instead of giving the ccd size manually. Because it is really
> very tedious to check for the ccd size each time and then to proceed.
> Please help out.
> For example,
> in one of my data the ccd size that is 1K by 1k is given in header as,
...
Anything you can do "manually," you can do in a program. The hard
part is usually to make it robust.
Based on the headers you provided, it looks like you have FITS image
files. If you don't already have it, get the IDL Astronomy Library.
It has many routines for reading FITS images and tables. The easiest
one to use is MRDFITS(). MRDFITS() returns the image array which you
can query using SIZE() and then trim as needed.
Simple example:
filename = 'myfile.fits'
img = mrdfits(filename) ;; Read image
sz = size(img, /dim) ;; Determine size of image
szx = sz(0) ;; Number of columns
szy = sz(1) ;; Number of rows
img = img( (0+2):(szx-3) , (0+2):(szy-3) ) ;; Remove outermost two
rows and columns
Good luck,
Craig
|
|
|
Re: reading header and manipulating according to the header information [message #71007 is a reply to message #71006] |
Sat, 15 May 2010 08:02  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On May 15, 10:21 am, sid <gunvicsi...@gmail.com> wrote:
> Hi,
> Since I am using huge data of several years, different kind of
> ccds are used on different days. I need to trim the data to a size
> which depends on ccd size, is there any method to read the header
> information and take the ccd size from there and then to proceed
> further, instead of giving the ccd size manually. Because it is really
> very tedious to check for the ccd size each time and then to proceed.
> Please help out.
> For example,
> in one of my data the ccd size that is 1K by 1k is given in header as,
> NAXIS =
> 3
> NAXIS1 =
> 1024
> NAXIS2 =
> 1024
> NAXIS3 = 1
> regards
> sid
You can use STREGEX to search for those header lines and GETTOK to
pick out the value.
|
|
|