addfiles from thredds vs. looping through files

From: Sam McClatchie (NOAA Federal) <sam.mcclatchie_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 05 2014 - 11:24:49 MDT

Colleagues

I would like to subset some model output from a remote server that is
not setup for opendap selection across files
<http://oceanmodeling.pmc.ucsc.edu:8080/thredds/catalog/wc12.0_ccsra31_01/posterior/catalog.html>.
I could just loop through each file in turn, but addfiles() would be a
nicer way to access the whole directory of netcdf files, and concatenate
a redimensioned subset. I have no problem accessing a single file in the
directory using this code:

filename =
"http://oceanmodeling.pmc.ucsc.edu:8080/thredds/dodsC/wc12.0_coamps_woa_gls_v563_01/posterior/20140526_20140601_posterior_his.nc"

   exists = isfilepresent(filename)
   if(.not.exists) then
     print("OPeNDAP isfilepresent test unsuccessful.")
     print("Either file doesn't exist, or NCL does not have OPeNDAP
capabilities on this system")
   else
     print("OPeNDAP isfilepresent test successful.")
     f = addfile(filename,"r")
     vars = getfilevarnames(f)
     print(vars) ; should be (in any order): "l","j","i","cross","aloan",
                   ; "shot","order","bears"
   end if

;--------------------------------------
;;; output follows
---------------------------------------

Copyright (C) 1995-2014 - All Rights Reserved
  University Corporation for Atmospheric Research
  NCAR Command Language Version 6.2.0
  The use of this software is governed by a License Agreement.
  See http://www.ncl.ucar.edu/ for more details.
(0) OPeNDAP isfilepresent test successful.


Variable: vars
Type: string
Total Size: 1008 bytes
             126 values
Number of Dimensions: 1
Dimensions and sizes: [126]
Coordinates:
(0) ntimes
(1) ndtfast
(2) dt
(3) dtfast
(4) dstart
(5) nHIS
(6) ndefHIS
(7) nRST
(8) nADJ
(9) ndefADJ
(10) nTLM
(11) ndefTLM
(12) Nouter
(13) Ninner
(14) Falpha
(15) Fbeta
(16) Fgamma
(17) nl_tnu2
(18) ad_tnu2
(19) tl_tnu2
(20) nl_visc2
(21) ad_visc2
(22) tl_visc2
(23) Akt_bak
(24) Akv_bak
(25) Akk_bak
(26) Akp_bak
(27) ad_Akt_fac
(28) tl_Akt_fac
(29) ad_Akv_fac
(30) tl_Akv_fac
(31) rdrg
(32) rdrg2
(33) Zob
(34) Zos
(35) gls_p
(36) gls_m
(37) gls_n
(38) gls_cmu0
(39) gls_c1
(40) gls_c2
(41) gls_c3m
(42) gls_c3p
(43) gls_sigk
(44) gls_sigp
(45) gls_Kmin
(46) gls_Pmin
(47) Charnok_alpha
(48) Zos_hsig_alpha
(49) sz_alpha
(50) CrgBan_cw
(51) Znudg
(52) M2nudg
(53) M3nudg
(54) Tnudg
(55) rho0
(56) R0
(57) Tcoef
(58) Scoef
(59) gamma2
(60) LhessianEV
(61) Lprecond
(62) Lritz
(63) GradErr
(64) HevecErr
(65) Nmethod
(66) Rscheme
(67) Nrandom
(68) Hgamma
(69) Vgamma
(70) Hdecay
(71) Vdecay
(72) spherical
(73) xl
(74) el
(75) Vtransform
(76) Vstretching
(77) theta_s
(78) theta_b
(79) Tcline
(80) hc
(81) s_rho
(82) s_w
(83) Cs_r
(84) Cs_w
(85) user
(86) h
(87) f
(88) pm
(89) pn
(90) lon_rho
(91) lat_rho
(92) lon_u
(93) lat_u
(94) lon_v
(95) lat_v
(96) lon_psi
(97) lat_psi
(98) angle
(99) mask_rho
(100) mask_u
(101) mask_v
(102) mask_psi
(103) ocean_time
(104) zeta
(105) ubar
(106) DU_avg1
(107) DU_avg2
(108) vbar
(109) DV_avg1
(110) DV_avg2
(111) u
(112) v
(113) w
(114) temp
(115) salt
(116) AKv
(117) AKt
(118) AKs
(119) shflux
(120) ssflux
(121) EminusP
(122) sustr
(123) svstr
(124) bustr
(125) bvstr
[Finished in 0.6s]
;---------------------------------------------------------------------
but when I try to access multiple files I have a problem:
;----------------------------------------------------------------------
diri =
"http://oceanmodeling.pmc.ucsc.edu:8080/thredds/dodsC/wc12.0_coamps_woa_gls_v563_01/posterior/"
   st = "ls " + diri + "*.*"
   fils = systemfunc(st)
   print(diri)
   print(st)
   print(fils)
   exit()

;--------------------------
;;; output follows:
;--------------------------
ls: cannot access
http://oceanmodeling.pmc.ucsc.edu:8080/thredds/dodsC/wc12.0_coamps_woa_gls_v563_01/posterior/*.*:
No such file or directory

Variable: diri
Type: string
Total Size: 8 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0)
http://oceanmodeling.pmc.ucsc.edu:8080/thredds/dodsC/wc12.0_coamps_woa_gls_v563_01/posterior/


Variable: st
Type: string
Total Size: 8 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) ls
http://oceanmodeling.pmc.ucsc.edu:8080/thredds/dodsC/wc12.0_coamps_woa_gls_v563_01/posterior/*.*


Variable: fils
Type: string
Total Size: 8 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
Number Of Attributes: 1
   _FillValue : missing
(0) missing
[Finished in 0.2s]

;-----------------------------------------------------------------
I can easily list files in a local directory so I must be doing
something silly when accessing the remote server?

Thanks for any help,
Sam
--
email signature Sam McClatchie,
Supervisory oceanographer,
Fisheries oceanography, Ichthyoplankton, Ship Operations
Southwest Fisheries Science Center, NOAA,
8901 La Jolla Shores Dr.
La Jolla, CA 92037-1509, U.S.A.
email <Sam.McClatchie@noaa.gov>
Office: 858 546 7083, Cellular: 858 752 8495
Research home page <www.fishocean.info>



_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk


Received on Thu Jun 05 05:24:48 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT