2017-02-23 4 views
1

netcdf4 함수를 사용하여 netcdf3 파일에 쓰는 데 문제가 있습니다. 나는 변수 함수를 작성하여 시도하지만 나에게 오류를 제공합니다 netCDF의를 : 시도 netCDF의-4 작업을 netCDF의-3 파일 = NCpython에서 module netcdf4를 사용하여 NetCDF3 파일에 쓰기

nc = Dataset(root.fileName,'a',format="NETCDF4") 

Hycom_U = nc.createVariable('/variables/Hycom_U','float',('time','lat','lon',)) 

Hycom_V = nc.createVariable('/variables/Hycom_V','f4',('time','lat','lon',)) 

내가 수있는 netCDF의 3 개 작업은 무엇

root group (NETCDF3_CLASSIC data model, file format NETCDF3): 
    netcdf_library_version: 4.1.3 
    format_version: HFRNet_1.0.0 
    product_version: HFRNet_1.1.05 
    Conventions: CF-1.0 
    title: Near-Real Time Surface Ocean Velocity, Hawaii, 
2 km Resolution 
    institution: Scripps Institution of Oceanography 
    source: Surface Ocean HF-Radar 
    history: 22-Feb-2017 00:55:46: NetCDF file created 
22-Feb-2017 00:55:46: Filtered U and V by GDOP < 1.25 ; 
FMRC Best Dataset 
    references: Terrill, E. et al., 2006. Data Management and Real-time 
Distribution in the HF-Radar National Network. Proceedings 
of the MTS/IEEE Oceans 2006 Conference, Boston MA, 
September 2006. 
    creator_name: Mark Otero 
    creator_email: [email protected] 
    creator_url: http://cordc.ucsd.edu/projects/mapping/ 
    summary: Surface ocean velocities estimated from HF-Radar are 
representative of the upper 0.3 - 2.5 meters of the 
ocean. The main objective of near-real time 
processing is to produce the best product from 
available data at the time of processing. Radial 
velocity measurements are obtained from individual 
radar sites through the U.S. HF-Radar Network. 
Hourly radial data are processed by unweighted 
least-squares on a 2 km resolution grid of Hawaii 
to produce near real-time surface current maps. 
    geospatial_lat_min: 20.487279892 
    geospatial_lat_max: 21.5720806122 
    geospatial_lon_min: -158.903594971 
    geospatial_lon_max: -157.490005493 
    grid_resolution: 2km 
    grid_projection: equidistant cylindrical 
    regional_description: Unites States, Hawaiian Islands 
    cdm_data_type: GRID 
    featureType: GRID 
    location: Proto fmrc:HFRADAR,_US_Hawaii,_2km_Resolution,_Hourly_RTV 
    History: Translated to CF-1.0 Conventions by Netcdf-Java CDM (NetcdfCFWriter) 
Original Dataset = fmrc:HFRADAR,_US_Hawaii,_2km_Resolution,_Hourly_RTV; Translation Date = Thu Feb 23 13:35:32 GMT 2017 
    dimensions(sizes): time(25), lat(61), lon(77) 
    variables(dimensions): float32 u(time,lat,lon), float64 time_run(time), float64 time(time), float32 lat(lat), float32 lon(lon), float32 v(time,lat,lon) 
    groups: 

파일에 데이터를 추가하는 데 사용 하시겠습니까? 데이터를 직접 추가하는 nc.variables["Hycom_U"]=U2을 사용하여 수동으로 데이터를 추가 할 수 있다는 것을 알았지 만 그 밖의 것은 없습니다. 이 작업을 수행하는 더 좋은 방법이 있습니까?

답변

0

나는 그것을 알아 냈다! 나는 단순히 경로를 varname으로 사용할 수 없었습니다.

는 Hycom_U = nc.createVariable는 ('Hycom_U', '유동'('시각', '북', '경도'))

제대로 저 변수를 만들었다.

1

나는 문제가 당신이 netCDF4 형식으로 파일을 주장하고 있다는 것입니다 믿습니다

nc = Dataset(root.fileName,'a',format="NETCDF4")` 

하지만 당신은 정말 netCDF3 있다는 표시하려면 :

nc = Dataset(root.fileName,'a',format="NETCDF3_CLASSIC") 

추가 문서를 찾을 수

here.

+0

불행히도 문제가 해결되지 않습니다. 나는 다른 형식을 시도하고 그들은 모두 같은 오류를 제공합니다. :( – EagleTamer