Re: PyNio

From: Rob Cermak <cermak_at_nyahnyahspammersnyahnyah>
Date: Wed, 20 Sep 2006 18:57:28 -0800 (AKDT)

Joe,

You will likely get multiple answers for this one. Python allows string
substitutions:

for k in range(0,len(orbit)):
  fl =
'/Users/satgroup/Aotearoa_Project/%s/L2/MISR_AM1_TC_STEREO_P%s_O%s_F08_0015.hdf'
% (orbit[k], path, orbit[k])
  f = Nio.open_file(fl)

Another useful python library is glob. File pattern matcher.

import glob
for k in range(0,len(orbit)):
  for fl in
glob.glob('/Users/satgroup/Aotearoa_Project/%s/L2/MISR_AM1_TC_STEREO*' %
(orbit[k])):
    f = Nio.open_file(fl)

Welcome to python!

Rob

On Wed, September 20, 2006 5:28 pm, Satellite Data Research Group wrote:
> Hi,
>
> I'm working with data from the Terra satellite and I'm using PyNio to
> open the files. However, I need to be able to open more than one file,
> I'm using a 'for' loop:
> for k in range(0,len(orbit)):
> fl =
'/Users/satgroup/Aotearoa_Project/'+orbit[k]+'/L2/MISR_AM1_TC_STEREO_P'+path+'_O'
> +orbit[k]+'_F08_0015.hdf'
> f = Nio.open_file(fl)
>
> Which works, but the problem is that the last section of the
> string('F08_0015') is not the same for all the files. It is possible
> to create another 'for' loop to fix this but would be quite time
> consuming. I've tried using macintosh alias' but PyNIO dosen't want to
> open them, and I don't really want to rename all the files. Could
> anyone suggest a method I could use to open the files that would bypass
> the need to specify the 'F08_0015' section?
>
> Thanks very much,
> Joe Corbett
>
> Satellite Data Research Group
> Physics Dept
> University of Auckland
>
> -----------------------------------------------------------------------
> This mail sent through University of Auckland http://www.auckland.ac.nz
>
> _______________________________________________
> pyngl-talk mailing list
> pyngl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>

-- 
Alaska Ocean Observing System
Database Manager
907-474-7948
_______________________________________________
pyngl-talk mailing list
pyngl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
Received on Wed Sep 20 2006 - 20:57:28 MDT

This archive was generated by hypermail 2.2.0 : Wed Sep 27 2006 - 09:59:34 MDT