begin ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Part1: Reading CSV files(stations_NW.csv, rbscReport_edited5_NW_R24h_Meteomanz.csv) print("Part1: Reading .csv files (stations_NW.csv)") ;(rbscReport_edited5_NW_R24h_Meteomanz.csv) fname_NW = "stations_NW.csv" lines_NW = asciiread(fname_NW,-1,"string") delim = "," ;---Read fields 1-5 from fname_Report station_id_NW = tointeger(str_get_field(lines_NW(1:),1,delim)) icao_code_NW = str_get_field(lines_NW(1:),2,delim) st_name_NW = str_get_field(lines_NW(1:),3,delim) lat_NW = tofloat(str_get_field(lines_NW(1:),4,delim)) lon_NW = tofloat(str_get_field(lines_NW(1:),5,delim)) ;---Print the information print("End Part1 Reading .csv files (stations_NW.csv)") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Part2: Interpolating SMAP data for April 2016 to April 2017 print("Part2: Interpolating SMAP files") diri = "./" fili = systemfunc("cd "+diri+" ; ls SMAP_L3_SM_P_20170*h5") nfili= dimsizes(fili) filesc= str_get_cols(fili,23,30) pthi = diri + fili print(pthi) print("================") SMAP_fod=new((/dimsizes(fili),dimsizes(lat_NW)/),float) ;---Open files; 'src_file' is type list src_file = addfiles(pthi, "r") ;---Set group; begin and end with / grp_smrd = "/Soil_Moisture_Retrieval_Data_AM/" var_long_name = "SMAP: Soil Moisture" ; default long_name is too long ;---Set variable name varName = "soil_moisture" do nf=0,nfili-1 print("nf="+nf+"; "+fili(nf)) ;---Same lat/lon dimension sizes but maybe different -9999.0 latName = "latitude" lat_path = grp_smrd + latName lat2d := src_file[nf]->$lat_path$ printVarSummary(lat2d) ;printMinMax(lat2d, 0) lonName = "longitude" lon_path = grp_smrd + lonName lon2d := src_file[nf]->$lon_path$ ;;;print("---printVarSummary(src_file[nf]->$lon_path$)---") ; printVarSummary(src_file[nf]->$lon_path$) printVarSummary(lon2d) ;;;exit ;printMinMax(lon2d, 0) ;---Manually add _FillValue lat2d@_FillValue = -9999.0 lon2d@_FillValue = -9999.0 ;printMinMax(lat2d,0) ;printMinMax(lon2d,0) ;---Set variable and group path var_path = grp_smrd + varName var := src_file[nf]->$var_path$ printVarSummary(var) ;;;exit ;printMinMax(var, 0) ;;;;;;;;;;;;;;;;; ;src_file = addfile(srcFileName,"r") ;temp = src_file->TEMP(0,0,:,:) Opt = True Opt@LLCorner = (/ -60.d, 0.d/) Opt@URCorner = (/ 60.d, 355.d/) Opt@GridMask = where(.not.ismissing(var),1,0) ; use "Mask2D" in NCL V6.2.1 and earlier Opt@InterpMethod = "bilinear" ; default Opt@ForceOverwrite = True Opt@PrintTimings = True Opt@Title = "NCEP Grid" curvilinear_to_SCRIP(src_file,var&LAT,var&LON,Opt) latlon_to_SCRIP(dstGridName,"5x5",Opt) ESMF_regrid_gen_weights(src_file,dstGridName,wgtFileName,Opt) temp_regrid = ESMF_regrid_with_weights(var,wgtFileName,Opt) SMAP_fo = linint2_points (lon,lat,temp_regrid,True, lon_pop, lat_pop, 0) ;;;;;;;;;;;;;;;;; ;fatal:linint2_points: If xi is not one-dimensional, ; then it must have one less dimension than fi ; So I added 2 following lines: lat1d = ndtooned(lat2d) lon1d = ndtooned(lon2d) ; SMAP_fo = linint2_points(lon2d,lat2d,var(lat | :, lon | :), False , lon_NW, lat_NW, 0) ; SMAP_fo = linint2_points(lon1d,lat1d,var(lat | :, lon | :), False , lon_NW, lat_NW, 0) ; SMAP_fo = linint2_points(lat1d,lon1d,var(DIM_000 | :, DIM_001 | :), False , lon_NW, lat_NW, 0) SMAP_fod(i,:)=SMAP_fo end do ;Generating dates 20160401-20170430 ;TIME = yyyymmdd_time(2016, 2017, "integer") ;time = TIME({20160401:20170430}) ; coordinate subscripting time = (/20170401, 20170403, 20170406, 20170409, 20170411, 20170414, 20170416, 20170417, 20170419, 20170420/) header_SMAP=(/" date lat lon sm_SMAP_Grid"/) ;;; hlist_SMAP=[/header_SMAP/] ;;; write_table("SMAP_Interpolated.txt","w",hlist_SMAP,"%s ") do i=0, dimsizes(lat_NW)-1 do j=0, dimsizes(time)-1 write_table("SMAP_Interpolated.txt","a",[/time(j),lat_NW(i),lon_NW(i),SMAP_fod(j,i)/], \ " %8i %7.4f %7.4f %5.1f") end do end do print("End Part2 Interpolating SMAP files") end