pro convert_investigator_csv_to_cdf region='southern_ocean' ulat=-42.0 & llat=-67 & llon=130.0 & rlon=152.0 ;big region ;***************************** ; Read in the ship track file ;***************************** ;shipfile='in2019_v01uwy1min.csv' shipdir='/Volumes/mace-group5/field_programs/investigator/in2018_v01/' shipfile='in2018_v01uwy1min.csv' ship_data=read_csv(shipdir+shipfile,n_table_header=1,table_header=in_table_header) ; Pull out the arrays lat=ship_data.field03 lon=ship_data.field04 date=ship_data.field01 time=ship_data.field02 ; There is a zero lat-lon value in there result=where(lat ne 0 and lon ne 0,count) if count gt 0 then begin lat=lat[result] lon=lon[result] date=date[result] time=time[result] endif ; Subset the time strings numtimes=n_elements(lat) yy=strmid(date,7,4) & yy=fix(yy) mm=make_array(numtimes,/int) r=where(strmid(date,3,3) eq 'Jan',c) if c gt 0 then mm[r]=1 r=where(strmid(date,3,3) eq 'Feb',c) if c gt 0 then mm[r]=2 r=where(strmid(date,3,3) eq 'Mar',c) if c gt 0 then mm[r]=3 dd=strmid(date,0,2) & dd=fix(dd) hh=strmid(time,0,2) & hh=fix(hh) mi=strmid(time,3,2) & mi=fix(mi) ss=strmid(time,6,2) & ss=fix(ss) julian_day=julday(mm,dd,yy,hh,mi,ss) ; Make the new filename date_str=string(yy[0],format='(I4)')+string(mm[0],format='(I02)')+$ string(dd[0],format='(I02)')+'.'+string(hh[0],format='(I02)')+$ string(mi[0],format='(I02)')+string(ss[0],format='(I02)')+'.'+$ string(yy[-1],format='(I4)')+string(mm[-1],format='(I02)')+$ string(dd[-1],format='(I02)')+'.'+string(hh[-1],format='(I02)')+$ string(mi[-1],format='(I02)')+string(ss[-1],format='(I02)') print,date_str ; Open the netcdf file voyage=strmid(shipfile,0,10) cdf_id=ncdf_create(voyage+'.ship_track.'+date_str+'.1min.cdf',/clobber) ; Define the dimensions numtimes=n_elements(julian_day) time_did=ncdf_dimdef(cdf_id,'time',numtimes) ; Define the variables julian_day_id=ncdf_vardef(cdf_id,'julian_day',time_did,/double) ncdf_attput,cdf_id,julian_day_id,'long_name','IDL julian day' ncdf_attput,cdf_id,julian_day_id,'units','day' ;time_id=ncdf_vardef(cdf_id,'time',time_did,/double) ;ncdf_attput,cdf_id,time_id,'long_name','acquisition time' ;ncdf_attput,cdf_id,time_id,'units','days since 1899-12-30 00:00:00 UTC' ;ncdf_attput,cdf_id,time_id,'calendar','gregorian' lat_id=ncdf_vardef(cdf_id,'lat',time_did,/double) ncdf_attput,cdf_id,lat_id,'long_name','latitude' ncdf_attput,cdf_id,lat_id,'units','degree_north' lon_id=ncdf_vardef(cdf_id,'lon',time_did,/double) ncdf_attput,cdf_id,lon_id,'long_name','longitude' ncdf_attput,cdf_id,lon_id,'units','degree_east' yy_id=ncdf_vardef(cdf_id,'year',time_did,/short) ncdf_attput,cdf_id,yy_id,'long_name','year' mm_id=ncdf_vardef(cdf_id,'month',time_did,/short) ncdf_attput,cdf_id,mm_id,'long_name','month' dd_id=ncdf_vardef(cdf_id,'day',time_did,/short) ncdf_attput,cdf_id,dd_id,'long_name','day' hh_id=ncdf_vardef(cdf_id,'hour',time_did,/short) ncdf_attput,cdf_id,hh_id,'long_name','hour' mi_id=ncdf_vardef(cdf_id,'minute',time_did,/short) ncdf_attput,cdf_id,mi_id,'long_name','minute' ss_id=ncdf_vardef(cdf_id,'second',time_did,/short) ncdf_attput,cdf_id,ss_id,'long_name','second' ; Change from define mode to data mode ncdf_control,cdf_id,/endef ; Put in the variables ncdf_varput,cdf_id,julian_day_id,julian_day ;ncdf_varput,cdf_id,time_id,time ncdf_varput,cdf_id,lat_id,lat ncdf_varput,cdf_id,lon_id,lon ncdf_varput,cdf_id,yy_id,yy ncdf_varput,cdf_id,mm_id,mm ncdf_varput,cdf_id,dd_id,dd ncdf_varput,cdf_id,hh_id,hh ncdf_varput,cdf_id,mi_id,mi ncdf_varput,cdf_id,ss_id,ss ; Close the file ncdf_close,cdf_id stop ;julian_day=julday(mm,dd,yy,hh,mi,ss) ; ;; Make this 1 minute resolution ;julian_day_1min=timegen(start=julday(mm[0],dd[0],yy[0],hh[0],mi[0]),$ ; final=julday(mm[-1],dd[-1],yy[-1],hh[-1],mi[-1]),units='Minutes',$ ; step_size=1) ; ;; Print the new time ;caldat,julian_day,mm,dd,yy,hh,mi,ss ;print,yy[0],mm[0],dd[0],hh[0],mi[0],ss[0] ;print,yy[-1],mm[-1],dd[-1],hh[-1],mi[-1],ss[-1] ;shipdir='/uufs/chpc.utah.edu/common/home/mace-group4/field_programs/socrates/ship_track/' ; fid=ncdf_open(shipdir+'socrates_ship_track.20180110.232300.20180221.052900.cdf') ; xid=ncdf_varid(fid,'julian_day') & ncdf_varget,fid,xid,julian_day_ship ; xid=ncdf_varid(fid,'lat') & ncdf_varget,fid,xid,lat_ship ; xid=ncdf_varid(fid,'lon') & ncdf_varget,fid,xid,lon_ship ; ncdf_close,fid ; end