使用IDL从NCDF4文件导入字符串

时间:2017-09-08 15:00:13

标签: idl-programming-language

我是IDL的新手

我正在将数据从NCDF4导入IDL。所有数字变量 完美进口。但是,站名称以200的数组形式出现。输出的示例是: -

84 82 69 76 69 87 95 65 69 82 79 32 32 32 0 0 0 0 0 0 0 0。

我从未遇到过这个问题。我尝试使用字符串命令,但这不起作用。如果我注释掉字符串命令,那么脚本的其余部分就可以完美地工作。我的脚本在

下面
  PRO Lat_Lon_Alt_Array                              

; This program is the extract the Latitute, Longigitude & Altitute
; with the Site name and file code. 
; The purpose is to output the above dimensions from the station files
; into a csv file.

COMPILE_OPt IDL2

the_file_list = file_search('D:/Rwork/Project/25_Files/','*.nc')

;---------------------------------------------------------------
n_files=N_Elements(the_file_list)  
station_name_st=string(n_files)                              ; try this
latitude_arr=DBLARR(n_files)
longitude_arr=DBLARR(n_files)
height_arr=DBLARR(n_files)

;----------------------------------------------------------------

FOR filein =  0, N_ElEMENTS (the_file_list)-1 DO BEGIN



 station = NCDF_OPEN(the_file_list[filein])

 ;fred= NCDF_VARINQ(station,station_name)

 NCDF_VARGET, station, 'station_name', station_name           
 NCDF_VARGET, station, 'lat', latitude
 NCDF_VARGET, station, 'lon', longitude
 NCDF_VARGET, station, 'alt', height

 stop
 ;-------------------------------------------------------
 ;station_name_st[filein]=station_name
 latitude_arr[filein]=latitude
 longitude_arr[filein]=longitude
 height_arr[filein]=height
 ;-----------------------------------------------------

 Print,the_file_list[filein]
 Print, 'station_name'
 Print, station_name
 Print,'lat'
 Print,latitude
 Print,'lon'
 print,longitude
 Print,'alt'
 Print,height


 HEADER=['File_Address','Latitude','Longitude','Altitude']

 ENDFOR

 WRITE_CSV,   'LatLon.csv',the_file_list,latitude_arr,longitude_arr,height_arr,$
 HEADER=HEADER,TABLE_HEADER='LAT,LON & ALT OF STATIONS'

 RETURN
 END

1 个答案:

答案 0 :(得分:1)

在某些情况下,NetCDF文件存储"字符串"作为字节数组。您的station_name变量似乎是其中一种情况。您只需使用STRING函数在使用station_name程序读取NCDF_VARGET后转换NCDF_VARGET, station, 'station_name', station_name PRINT, station_name 84 82 69 76 69 87 95 65 69 82 79 32 32 32 0 0 0 0 0 0 0 0 station_name = STRING(station_name) PRINT, station_name TRELEW_AERO

viewport = jQuery("meta[name='viewport']");
original = viewport.attr("content");
force_scale = original + ", maximum-scale=1";
viewport.attr("content", force_scale); // IGNORED!
viewport.attr("content", original);