comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Why is my code truncating my image dimensions?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Why is my code truncating my image dimensions? [message #81056] Mon, 13 August 2012 08:33 Go to next message
adhdunn is currently offline  adhdunn
Messages: 11
Registered: July 2012
Junior Member
Hi!

I am trying to read in two datasets (Landsat and NLDAS) using a .ctl file but my code seems to be truncating the last digit of the Landsat image. I have run through various trials to see why this is happening, with not luck. If someone could take a look below and see if a glaring error pops out I would greatly appreciate it!

NOTE*** The Landsat image has dimensions 7931 x 7001. The NLDAS file has dimensions of 224 x 464. The NLDAS data dimensions read in correctly, but the Landsat image prints 793 and 700. In the code below 'nmx' and 'nmy' represent the Landsat input while 'nx' and 'ny' represent the NDLAS input. My original thought was that the data type was set wrong, but I no longer think this to be the case after several test. Also, the truncation occurs when it is first read in not after the FIX operation (if that matters).

Any suggestions would be appreciated! Thank you!!

Here is the code:

OPENR, 1,fname_ctl

nmx = 0L & nmy = 0L & nx = 0L & ny = 0L & rad_fname = '' & $
fname0 = '' & fname1 = '' & fname2 = '' & fname3= '' & fname4= '' & fname5= '' & $ fname6= '' & fname7= '' & fname8= '' & fname9= '' & fname10= '' & $
fname11= '' & fname12= '' & fname13= '' & fname14= '' & fname15= '' & $
fname16= '' & fname17= '' & fname18= '' & fname19= '' & fname20= '' & $
fname21= '' & fname22= '' & fname23='' & fname50= ''

; Read in each line

WHILE (~ EOF(1)) DO BEGIN

READF,1,$
FORMAT = '(I3,3(/,I3),25(/,A100),/,A100)',nmx,nmy,nx,ny,rad_fname, fname0, $
fname1,fname2,fname3,fname4,fname5,fname6,fname7,fname8,fnam e9,fname10,$
fname11,fname12,fname13,fname14,fname15,fname16,fname17,fnam e18,fname19,fname20,$ fname21,fname22,fname23,fname50

PRINT,$
FORMAT = '(I3,3(/,I3),25(/,A100),/,A100)',nmx,nmy,nx,ny,rad_fname, fname0, $
fname1,fname2,fname3,fname4,fname5,fname6,fname7,fname8,fnam e9,fname10,$
fname11,fname12,fname13,fname14,fname15,fname16,fname17,fnam e18,fname19,fname20,$ fname21,fname22,fname23,fname50


ENDWHILE

; Convert the read in values to proper type

nx = FIX(nx, TYPE = 3) ; nx and ny are the dimensions of the NLDAS data.
ny = FIX(ny, TYPE = 3)

nmx = FIX(nmx, TYPE = 3) ; nmx and nmy are the dimensions of the LANDSAT
nmy = FIX(nmy, TYPE = 3) ; image taken from the header information.

****THIS IS WHAT PRINTS OUT-
793
700
224
464
Re: Why is my code truncating my image dimensions? [message #81147 is a reply to message #81056] Tue, 14 August 2012 04:29 Go to previous message
adhdunn is currently offline  adhdunn
Messages: 11
Registered: July 2012
Junior Member
Yes I can see how formatting can work very well in your case.

Hopefully I can crack this darn set of programs today and try to move forward. Of course I will most likely be moving on to another code and another set of problems ;)

I am also surrounded by a lot of people with a wealth of knowledge, unfortunately that knowledge is just not IDL based.

Best of luck to you and thanks again for your help! You will probably see my name on this site a bit more in the future.

Cheers!
Allisyn



On Monday, August 13, 2012 11:33:51 AM UTC-4, adh...@gmail.com wrote:
> Hi!
>
>
>
> I am trying to read in two datasets (Landsat and NLDAS) using a .ctl file but my code seems to be truncating the last digit of the Landsat image. I have run through various trials to see why this is happening, with not luck. If someone could take a look below and see if a glaring error pops out I would greatly appreciate it!
>
>
>
> NOTE*** The Landsat image has dimensions 7931 x 7001. The NLDAS file has dimensions of 224 x 464. The NLDAS data dimensions read in correctly, but the Landsat image prints 793 and 700. In the code below 'nmx' and 'nmy' represent the Landsat input while 'nx' and 'ny' represent the NDLAS input. My original thought was that the data type was set wrong, but I no longer think this to be the case after several test. Also, the truncation occurs when it is first read in not after the FIX operation (if that matters).
>
>
>
> Any suggestions would be appreciated! Thank you!!
>
>
>
> Here is the code:
>
>
>
> OPENR, 1,fname_ctl
>
>
>
> nmx = 0L & nmy = 0L & nx = 0L & ny = 0L & rad_fname = '' & $
>
> fname0 = '' & fname1 = '' & fname2 = '' & fname3= '' & fname4= '' & fname5= '' & $ fname6= '' & fname7= '' & fname8= '' & fname9= '' & fname10= '' & $
>
> fname11= '' & fname12= '' & fname13= '' & fname14= '' & fname15= '' & $
>
> fname16= '' & fname17= '' & fname18= '' & fname19= '' & fname20= '' & $
>
> fname21= '' & fname22= '' & fname23='' & fname50= ''
>
>
>
> ; Read in each line
>
>
>
> WHILE (~ EOF(1)) DO BEGIN
>
>
>
> READF,1,$
>
> FORMAT = '(I3,3(/,I3),25(/,A100),/,A100)',nmx,nmy,nx,ny,rad_fname, fname0, $
>
> fname1,fname2,fname3,fname4,fname5,fname6,fname7,fname8,fnam e9,fname10,$
>
> fname11,fname12,fname13,fname14,fname15,fname16,fname17,fnam e18,fname19,fname20,$ fname21,fname22,fname23,fname50
>
>
>
> PRINT,$
>
> FORMAT = '(I3,3(/,I3),25(/,A100),/,A100)',nmx,nmy,nx,ny,rad_fname, fname0, $
>
> fname1,fname2,fname3,fname4,fname5,fname6,fname7,fname8,fnam e9,fname10,$
>
> fname11,fname12,fname13,fname14,fname15,fname16,fname17,fnam e18,fname19,fname20,$ fname21,fname22,fname23,fname50
>
>
>
>
>
> ENDWHILE
>
>
>
> ; Convert the read in values to proper type
>
>
>
> nx = FIX(nx, TYPE = 3) ; nx and ny are the dimensions of the NLDAS data.
>
> ny = FIX(ny, TYPE = 3)
>
>
>
> nmx = FIX(nmx, TYPE = 3) ; nmx and nmy are the dimensions of the LANDSAT
>
> nmy = FIX(nmy, TYPE = 3) ; image taken from the header information.
>
>
>
> ****THIS IS WHAT PRINTS OUT-
>
> 793
>
> 700
>
> 224
>
> 464
Re: Why is my code truncating my image dimensions? [message #81148 is a reply to message #81056] Tue, 14 August 2012 02:30 Go to previous message
Helder Marchetto is currently offline  Helder Marchetto
Messages: 520
Registered: November 2011
Senior Member
On Tuesday, August 14, 2012 1:49:03 AM UTC+2, adh...@gmail.com wrote:
> Hi Helder,
>
>
>
> Thanks for all the help!! Your explanation of the Format components was great and will hopefully guide me in the future!
>
>
>
> Yes working with this code has been a nightmare. There are 5 programs that all run together to read in the NLDAS files (which come in GRIB format) and the Landsat image. It is always hard to try and take an established program, or set of programs, and adapt it to your own needs. This is what I have been working on and I find that there are often steps I would have done differently, unfortunately I am still quite a newbie with IDL and so I don't yet have the luxury to re-invent the wheel per-se.
>
>
>
> Thanks also for the alternative way to read in the data, I am sure it will make this process much easier.
>
>
>
> Best to you and Thanks Again!!
>
> Allisyn
>
>
>
>
>
> On Monday, August 13, 2012 4:56:18 PM UTC-4, Helder wrote:
>
>> On Monday, August 13, 2012 8:52:00 PM UTC+2, adh...@gmail.com wrote:
>
>>
>
>>> Yes, I agree it is the format line. After I changed the text to read as you suggested, the first program worked great :) I am simply not accustomed to working with the format command and therefore I am having a hard time figuring out the context of all the values. I understand that 'F' is used for float, 'I' for integer, 'A' for characters. I also understand that if you have 'A100' then your file name (or whatever) can not exceed 100 characters.
>
>>
>
>>>
>
>>
>
>>> However I am struggling with other inputs like:
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> '/'-- does this mean a new line or return?
>
>>
>
>>>
>
>>
>
>>> ','-- does this mean the next command?
>
>>
>
>>>
>
>>
>
>>> '()'-- why would you have some values in additional parenthesis while others not
>
>>
>
>>>
>
>>
>
>>> 'F6.3'-- what is the relevance of the 6.3. I see (below) that there are 6 values for the number, but why the .3?
>
>>
>
>>>
>
>>
>
>>> 'A100,5'-- what is the relevance of ,5?
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Anyways this is the header information for the .ctl file that you requested:
>
>>
>
>>>
>
>>
>
>>> 7931
>
>>
>
>>>
>
>>
>
>>> 7001
>
>>
>
>>>
>
>>
>
>>> 224
>
>>
>
>>>
>
>>
>
>>> 464
>
>>
>
>>>
>
>>
>
>>> 25.063
>
>>
>
>>>
>
>>
>
>>> -124.938
>
>>
>
>>>
>
>>
>
>>> E:\ET code\workassignment\NEWwork\workassignment\final_simple_meth od_code\latlon_grid.dat
>
>>
>
>>>
>
>>
>
>>> 33.0
>
>>
>
>>>
>
>>
>
>>> 30.0
>
>>
>
>>>
>
>>
>
>>> -86.5
>
>>
>
>>>
>
>>
>
>>> -83.0
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> right now the format line is written as:
>
>>
>
>>>
>
>>
>
>>> (I5,/,I5(/,I5),/,F6.3,/,F8.3,/,A100,5(/,F5.1))',nmx,nmy,nx,n y,lat1,lon1,fname1,$
>
>>
>
>>>
>
>>
>
>>> TM_lat_ul,TM_lat_ll,TM_lon_ul,TM_lon_ll
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Does that help you?
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> :) A
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> On Monday, August 13, 2012 2:19:48 PM UTC-4, Helder wrote:
>
>>
>
>>>
>
>>
>
>>>> On Monday, August 13, 2012 6:27:58 PM UTC+2, adh...@gmail.com wrote:
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > Hi Helder,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > Thank you for your response! I have inserted your suggested change, however this particular program works off of several separate programs. Another section of code follows. This one will also need to be changed as well and simply replacing the 3 with a 4 is not working. Do you have a suggestion as to how this line should be altered to accommodate the new text you suggested?
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > FORMAT = '(I3,3(/,I3),/,F6.3,/,F8.3,/,A100,4(/,F5.1))',nmx,nmy,nx,ny, lat1,lon1,fname1,$
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > TM_lat_ul,TM_lat_ll,TM_lon_ul,TM_lon_ll
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > Thank you!
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > > Hi,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > > although I have no experience with such images, my first guess is that you need to change the FORMAT in the READF command.
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > > Using '(I3)' will read 3 digits of integer numbers. I would put a I4. Can you check what comes up by doing that?
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > > Therefore try with: FORMAT = '(I4,/,I4,2(/,I4),25(/,A100),/,A100)'
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > > (I have not tested this...!!!)
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > > Cheers,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > > Helder
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Sorry, I don't because I don't know how the file header actually looks like.
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> But I do think that you're having a problem with truncation in the format line.
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> If you send me the first four or five header lines I can have a go at it. I'm not into satellite images, therefore I can't find such information quickly.
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Cheers,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Helder
>
>>
>
>>
>
>>
>
>> Hi,
>
>>
>
>> well, I'm not that good with formats and I personally don't like the way your code is written down because it is for people like me with a limited experience difficult to read.
>
>>
>
>> A few tips to make the code "understandable":
>
>>
>
>> 1) using a & is the same as writing two lines. When debugging, the & make your life hell
>
>>
>
>> 2) read one line at a time. This way you can look at what is in it and debugging will be a lot easier.
>
>>
>
>>
>
>>
>
>> That said, I would rewrite the code necessary for the image size this way:
>
>>
>
>>
>
>>
>
>> LandSatFileName = 'C:\YourDirectory\YourFile.txt'
>
>>
>
>> GET_LUN, LandSatUnit
>
>>
>
>> OPENR, LandSatUnit, LandSatFileName
>
>>
>
>> nmx = 0L
>
>>
>
>> nmy = 0L
>
>>
>
>> nx = 0L
>
>>
>
>> ny = 0L
>
>>
>
>>
>
>>
>
>> READF,LandSatUnit, MyString
>
>>
>
>> nmx = FIX(MyString, TYPE=3)
>
>>
>
>> READF,LandSatUnit, MyString
>
>>
>
>> nmy = FIX(MyString, TYPE=3)
>
>>
>
>> READF,LandSatUnit, MyString
>
>>
>
>> nx = FIX(MyString, TYPE=3)
>
>>
>
>> READF,LandSatUnit, MyString
>
>>
>
>> ny = FIX(MyString, TYPE=3)
>
>>
>
>> PRINT, 'nmx=',nmx
>
>>
>
>> PRINT, 'nmy=',nmy
>
>>
>
>> PRINT, 'nx=',nx
>
>>
>
>> PRINT, 'ny=',ny
>
>>
>
>> CLOSE, LandSatUnit
>
>>
>
>>
>
>>
>
>> If and when you have time you might look at the FORMAT keyword and you can learn a lot about it... however, the above code works fine. It occupies more lines, but it won't be dramatic in terms of CPU as compared to reading an image file of 7931x7001 pixel.
>
>>
>
>>
>
>>
>
>> Some quick answers to your format questions (only the things I know).
>
>>
>
>> - f6.3 represents a floating point number made out of 6 digits (dot included) of which 3 after the dot.
>
>>
>
>> - if the () have a number in front that represents the number of repetitions of what is in the parenthesis
>
>>
>
>> - the comma separates commands
>
>>
>
>> - I *think* that the / is indeed a new line
>
>>
>
>>
>
>>
>
>>> Does that help you?
>
>>
>
>>
>
>>
>
>> Well, I hope it helps you! ;-)
>
>>
>
>>
>
>>
>
>> For more info, look in the IDL help for "Format Codes" or follow:
>
>>
>
>> IDL Programming -> Concepts -> Format Codes
>
>>
>
>>
>
>>
>
>> It can get pretty complicated, but it is also very powerful.
>
>>
>
>>
>
>>
>
>> Cheers,
>
>>
>
>> h

Hi,
reinventing the wheel is not a good idea. I have no idea what NLDAS,GRIB and Landsat images are... I deal with small images (from microscopes) not with huge images of the earth!

I guess there is one more thing I personally don't like about using formatted input as in your case. Normally, I like using formatted output only to generate tables that look like this:

0123 0056 5392 0003
0005 4501 0893 0159
...

Where you can see that padding with zeros makes the tables "more" readable (Engrish funny) when opening the data as a text. It for sure looks better than this:

123 56 5392 3
5 4501 893 159

I normally use one of two ways to read such lines in. If I have a padded table, than it is okay to read it in using format because the number of characters per number are well defined.
In case I want to read a non-zero-padded table, than I rather read each line as a whole with the commands:
MyLine = ''
readf, MyUnit, MyLine

and then break up the line using the STRSPLIT function.
In case my array is made of 4 integer numbers x n-Lines, than I will define an array such as:

MyArr = INTARR(4,n)

And after each MyLine read add this to the array by using:

MyArr[*,i] = STRSPLIT(MyLine,/EXTRACT)

But this is no a general approach. It depends on how the data was written in the first place.

So, to conclude, I find the using of formated input quite tricky in a way that it works best only when the same person that wrote the output is also reading it... And that is most often not the case.

Anyway, I'm also fighting my way through programming and around here there are lots of people with lots of experience that can give you much more advice on how to manage you data, both in input and output.

Cheers and good luck,
Helder
Re: Why is my code truncating my image dimensions? [message #81149 is a reply to message #81056] Mon, 13 August 2012 16:49 Go to previous message
adhdunn is currently offline  adhdunn
Messages: 11
Registered: July 2012
Junior Member
Hi Helder,

Thanks for all the help!! Your explanation of the Format components was great and will hopefully guide me in the future!

Yes working with this code has been a nightmare. There are 5 programs that all run together to read in the NLDAS files (which come in GRIB format) and the Landsat image. It is always hard to try and take an established program, or set of programs, and adapt it to your own needs. This is what I have been working on and I find that there are often steps I would have done differently, unfortunately I am still quite a newbie with IDL and so I don't yet have the luxury to re-invent the wheel per-se.

Thanks also for the alternative way to read in the data, I am sure it will make this process much easier.

Best to you and Thanks Again!!
Allisyn


On Monday, August 13, 2012 4:56:18 PM UTC-4, Helder wrote:
> On Monday, August 13, 2012 8:52:00 PM UTC+2, adh...@gmail.com wrote:
>
>> Yes, I agree it is the format line. After I changed the text to read as you suggested, the first program worked great :) I am simply not accustomed to working with the format command and therefore I am having a hard time figuring out the context of all the values. I understand that 'F' is used for float, 'I' for integer, 'A' for characters. I also understand that if you have 'A100' then your file name (or whatever) can not exceed 100 characters.
>
>>
>
>> However I am struggling with other inputs like:
>
>>
>
>>
>
>>
>
>> '/'-- does this mean a new line or return?
>
>>
>
>> ','-- does this mean the next command?
>
>>
>
>> '()'-- why would you have some values in additional parenthesis while others not
>
>>
>
>> 'F6.3'-- what is the relevance of the 6.3. I see (below) that there are 6 values for the number, but why the .3?
>
>>
>
>> 'A100,5'-- what is the relevance of ,5?
>
>>
>
>>
>
>>
>
>> Anyways this is the header information for the .ctl file that you requested:
>
>>
>
>> 7931
>
>>
>
>> 7001
>
>>
>
>> 224
>
>>
>
>> 464
>
>>
>
>> 25.063
>
>>
>
>> -124.938
>
>>
>
>> E:\ET code\workassignment\NEWwork\workassignment\final_simple_meth od_code\latlon_grid.dat
>
>>
>
>> 33.0
>
>>
>
>> 30.0
>
>>
>
>> -86.5
>
>>
>
>> -83.0
>
>>
>
>>
>
>>
>
>> right now the format line is written as:
>
>>
>
>> (I5,/,I5(/,I5),/,F6.3,/,F8.3,/,A100,5(/,F5.1))',nmx,nmy,nx,n y,lat1,lon1,fname1,$
>
>>
>
>> TM_lat_ul,TM_lat_ll,TM_lon_ul,TM_lon_ll
>
>>
>
>>
>
>>
>
>> Does that help you?
>
>>
>
>>
>
>>
>
>> :) A
>
>>
>
>>
>
>>
>
>>
>
>>
>
>>
>
>>
>
>> On Monday, August 13, 2012 2:19:48 PM UTC-4, Helder wrote:
>
>>
>
>>> On Monday, August 13, 2012 6:27:58 PM UTC+2, adh...@gmail.com wrote:
>
>>
>
>>>
>
>>
>
>>>> Hi Helder,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Thank you for your response! I have inserted your suggested change, however this particular program works off of several separate programs. Another section of code follows. This one will also need to be changed as well and simply replacing the 3 with a 4 is not working. Do you have a suggestion as to how this line should be altered to accommodate the new text you suggested?
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> FORMAT = '(I3,3(/,I3),/,F6.3,/,F8.3,/,A100,4(/,F5.1))',nmx,nmy,nx,ny, lat1,lon1,fname1,$
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> TM_lat_ul,TM_lat_ll,TM_lon_ul,TM_lon_ll
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> Thank you!
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > Hi,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > although I have no experience with such images, my first guess is that you need to change the FORMAT in the READF command.
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > Using '(I3)' will read 3 digits of integer numbers. I would put a I4. Can you check what comes up by doing that?
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > Therefore try with: FORMAT = '(I4,/,I4,2(/,I4),25(/,A100),/,A100)'
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > (I have not tested this...!!!)
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > Cheers,
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> >
>
>>
>
>>>
>
>>
>
>>>>
>
>>
>
>>>
>
>>
>
>>>> > Helder
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Sorry, I don't because I don't know how the file header actually looks like.
>
>>
>
>>>
>
>>
>
>>> But I do think that you're having a problem with truncation in the format line.
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> If you send me the first four or five header lines I can have a go at it. I'm not into satellite images, therefore I can't find such information quickly.
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>>
>
>>
>
>>> Cheers,
>
>>
>
>>>
>
>>
>
>>> Helder
>
>
>
> Hi,
>
> well, I'm not that good with formats and I personally don't like the way your code is written down because it is for people like me with a limited experience difficult to read.
>
> A few tips to make the code "understandable":
>
> 1) using a & is the same as writing two lines. When debugging, the & make your life hell
>
> 2) read one line at a time. This way you can look at what is in it and debugging will be a lot easier.
>
>
>
> That said, I would rewrite the code necessary for the image size this way:
>
>
>
> LandSatFileName = 'C:\YourDirectory\YourFile.txt'
>
> GET_LUN, LandSatUnit
>
> OPENR, LandSatUnit, LandSatFileName
>
> nmx = 0L
>
> nmy = 0L
>
> nx = 0L
>
> ny = 0L
>
>
>
> READF,LandSatUnit, MyString
>
> nmx = FIX(MyString, TYPE=3)
>
> READF,LandSatUnit, MyString
>
> nmy = FIX(MyString, TYPE=3)
>
> READF,LandSatUnit, MyString
>
> nx = FIX(MyString, TYPE=3)
>
> READF,LandSatUnit, MyString
>
> ny = FIX(MyString, TYPE=3)
>
> PRINT, 'nmx=',nmx
>
> PRINT, 'nmy=',nmy
>
> PRINT, 'nx=',nx
>
> PRINT, 'ny=',ny
>
> CLOSE, LandSatUnit
>
>
>
> If and when you have time you might look at the FORMAT keyword and you can learn a lot about it... however, the above code works fine. It occupies more lines, but it won't be dramatic in terms of CPU as compared to reading an image file of 7931x7001 pixel.
>
>
>
> Some quick answers to your format questions (only the things I know).
>
> - f6.3 represents a floating point number made out of 6 digits (dot included) of which 3 after the dot.
>
> - if the () have a number in front that represents the number of repetitions of what is in the parenthesis
>
> - the comma separates commands
>
> - I *think* that the / is indeed a new line
>
>
>
>> Does that help you?
>
>
>
> Well, I hope it helps you! ;-)
>
>
>
> For more info, look in the IDL help for "Format Codes" or follow:
>
> IDL Programming -> Concepts -> Format Codes
>
>
>
> It can get pretty complicated, but it is also very powerful.
>
>
>
> Cheers,
>
> h
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Why is my code truncating my image dimensions?
Next Topic: Memory Allocation Problem

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:36:39 PDT 2025

Total time taken to generate the page: 0.00776 seconds