; This is an example of the commands that can be used to produce a lunar calibration NetCDF file ; accepted by the GIRO executable. The commands were extracted from the routine which prepares the data ; of MSGs, MTP, and MTSAT2 in EUMETSAT. ; The comments have the aim of guiding the user in the preparation of his/her own script. ; Please notice that this file cannot be compiled and used in this format! IT MUST BE MODIFIED ; ACCORDING TO THE USER'S NEEDS. function NCDF_lun_obs, ; set your arguments and/or keywords ; Satellite name sSat = ; the satellite name (e.g. 'MTSAT') PLEASE NOTE THAT THE SUFFIX 2 OF MTSAT2 IS HANDLES IN stMeta!!! ; Number of channels iChan_Num = ; set the nnumber of channels ; Fill the following structures with useful information ; (here you find the example of the JMA/MTSAT2 satellite) stMeta = create_struct( 'sChan_Name' , ['VIS'], $; one-element array (for multiple channels this is an array) 'sSat_Suff' , '2', $ 'sInst_Name' , 'Imager', $ 'sSatInst_Wmo_Code', '(172,295)', $ 'sSat_Pos_Ref' , 'ITRF93', $ 'dOvrsamp_Fa' , [1.75d0], $; one-element array (for multiple channels this is an array) 'sInstitute' , 'JMA', $ 'sData_Source' , 'MRAW', $ 'sDoc_Url' , 'N/A', $ 'sDoc_Doi' , 'N/A', $ 'sVersion' , 'v1.0.0' $ ) sLicenceJMA= ; This is a string with licencing conditions stGprc = create_struct( 'sProducer_Wmo' , 'JP-JMA-MSC', $ 'sOriginator_Wmo' , 'RJTD', $ 'sInstitute' , 'JMA', $ 'sLicence' , sLicenceJMA, $; Text from the previous string 'sCreator_Name' , 'System Engineering Division, Meteorological Satellite Center, Japan Meteorological Agency', $ 'sCreator_Email' , 'calmstr@dpc.kishou.go.jp',$ 'sCreator_Url' , 'http://mscweb.kishou.go.jp/monitoring/calibration.htm', $ 'sNaming_Authority', 'jp.go.jma.msc.gsics' $ ) ; Define dimensions iChan_Strlen = ; set the max length of variable chan iDate_Num = 1 ; Number of date MUST BE 1! iSat_Ref_Strlen = 6 ; Maximum length of variable, it comes from the string 'ITRF93' iSat_Xyz = 3 ; X, Y, and Z axis of satellite position ; As explained in the .pdf https://gsics.nesdis.noaa.gov/pub/Development/20140624/GSICS_ROLO_HighLevDescript_IODefinition_wiki.pdf ; imagettes from different channels are stored within a multidimensional array with two spatial dimensions and one dimension ; numbering the channels. The spatial dimensions are set to the largest possible dimension in the dataset. In the .pdf document ; this is explained in detail iCol_Num = ; set to the maximum possible number of imagette columns iRow_Num = iCol_Num ; largest squared imagette (Rows = Cols) ; Define variables ; Compulsory dDate = dblarr(iDate_Num) sChannel_Name = stMeta.sChan_Name sSat_Pos_Ref = stMeta.sSat_Pos_Ref dSat_Pos = dblarr(iSat_Xyz) dIrr_Obs = dblarr(iChan_Num) ; Additional dPix_Solid_Ang = dblarr(iChan_Num) dOvrsamp_Fa = dblarr(iChan_Num) iDc_Obs = lonarr(iChan_Num) dDc_Obs_Offset = dblarr(iChan_Num) iMoon_Pix_Num = dblarr(iChan_Num) ; Imagette iMoon_Pix_Thld = lonarr(iChan_Num) dRad_Obs_Imgt = dblarr(iChan_Num,iCol_Num,iRow_Num) iDc_Obs_Imgt = lonarr(iChan_Num,iCol_Num,iRow_Num) ; Initialize variables ; _FillValue d_FillValue = -999.0 i_FillValue = -999 dDate[*] = d_FillValue dSat_Pos[*] = d_FillValue dIrr_Obs[*] = d_FillValue dPix_Solid_Ang[*] = d_FillValue dOvrsamp_Fa[*] = d_FillValue iDc_Obs[*] = i_FillValue dDc_Obs_Offset[*] = d_FillValue iMoon_Pix_Num[*] = i_FillValue iMoon_Pix_Thld[*] = i_FillValue dRad_Obs_Imgt[*,*,*] = d_FillValue iDc_Obs_Imgt[*,*,*] = i_FillValue ; Hash of month name hMon_Idx = hash( 'JAN',1, 'FEB',2, 'MAR',3, 'APR', 4, 'MAY', 5, 'JUN', 6, $ 'JUL',7, 'AUG',8, 'SEP',9, 'OCT',10, 'NOV',11, 'DEC',12 ) ; wmo_data_category iWmo_Data_Category = 101 ; Imager data (satellite) ; wmo_international_data_subcategory iWmo_International_Data_Subcategory = 0 ; Multi-purpose VIS/IR imagery ; =================================================== ; Here the script uses the data from the user (e.g., satellite position, date, imagettes, etc.) ; PLEASE REFER TO THE .PDF DOCUMENT FOR THE UNITS! ; =================================================== for iCh = 0, iChan_Num -1 do begin ; Date and Satellite Position (just once!) if iCh eq 0 then begin dSat_Pos = ; the 3 component array with the satellite coordinates dDate[0] = ; the observation time in seconds (see .pdf file for the definition) sDate_File = ; the observation time used for netCDF file name (format YYYYMMDDhhmmss) ; THIS MUST BE THE SAME TIME USED TO DERIVE dDate[0]! endif ; ovrsamp_fa dOvrsamp_Fa[iCh] = stMeta.dOvrsamp_Fa[iCh] ; pix_solid_ang dPix_Solid_Ang[iCh] = ; the value of the pixel solid angle ; moon_pix_thld iMoon_Pix_Thld[iCh] = ; the value of the threshold in DC with the minimum value from the illuminated portion of the Moon ; Handling imagettes ; rad_obs_imgt and dc_obs_imgt fRad = ; the radiance imagette for the channel iCh (for cycle) iDC = ; the DC imagette for the channel iCh (for cycle) ; The dimension of the imagette; these must be smaller than iCol_Num and iRow_Num (see above) iRealDims = size(fRad) ; THE IMAGETTE fRad and iDC MUST HAVE THE SAME DIMENSIONS, IN DETAIL ONE SHOULD BE ABLE TO GET ; fRad FROM iDC USING THE CALIBRATION FORMULA ; Storing the imagettes from the channel iCh dRad_Obs_Imgt[iCh,0:iRealDims[1]-1,0:iRealDims[2]-1] = fRad iDc_Obs_Imgt [iCh,0:iRealDims[1]-1,0:iRealDims[2]-1] = iDC dIrr_Obs[iCh] = ; the observed irradiance for the channel iCh iDc_Obs[iCh] = ; the observed DC signal dDc_Obs_Offset[iCh] = ; the observed offset iMoon_Pix_Num[iCh] = ; number pixels of the Moon endfor ; =================================================== ; Generate netCDF ; =================================================== ; Version name used for netCDF sVersion_Major = (strsplit(stMeta.sVersion,'.',/extract))[0] sVersion_Major = strmid(sVersion_Major,1,strlen(sVersion_Major)-1) ; remove 'v' ; Output file name sNcdfFile = 'W_'+stGprc.sProducer_Wmo+',VISNIR+SUBSET+MOON,' $ + sSat + stMeta.sSat_Suff + '+' + stMeta.sInst_Name + '_C_'+stGprc.sOriginator_Wmo+'_' + sDate_File $ + '_' + string(sVersion_Major,format='(I02)') + '.nc' ; Create netCDF iCdfid = NCDF_CREATE( sOutDir+sNcdfFile, /CLOBBER, /NETCDF4_FORMAT ) ; Define dimensions: iChid = NCDF_DIMDEF(iCdfid,'chan',iChan_Num) iChlenid = NCDF_DIMDEF(iCdfid,'chan_strlen',iChan_Strlen) iTid = NCDF_DIMDEF(iCdfid,'date',iDate_Num) iStrefid = NCDF_DIMDEF(iCdfid,'sat_ref_strlen',iSat_Ref_Strlen) iStposid = NCDF_DIMDEF(iCdfid,'sat_xyz',iSat_Xyz) iColid = NCDF_DIMDEF(iCdfid,'col',iCol_Num) iRowid = NCDF_DIMDEF(iCdfid,'row',iRow_Num) ;Get system time and convert into ISO 8601 format: CALDAT, SYSTIME(/JULIAN,/UTC), mm, dd, yyyy, hh, mn, ss sDatetime_Now = STRING(yyyy, mm, dd, hh, mn, ss, FORMAT='(i4.4,"-",i2.2,"-",i2.2,"T",i2.2,":",i2.2,":",i2.2,"Z")') sSatGlb=sSat ;Define Global attributes:.................................................. NCDF_ATTPUT,iCdfid,'Conventions' , "CF-1.6",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'Metadata_Conventions' , "Unidata Dataset Discovery v1.0",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'standard_name_vocabulary' , "CF Standard Name Table (Version 21, 12 January 2013)",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'project' , "Global Space-based Inter-Calibration System ",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'title' , sSatGlb+" "+stMeta.sInst_Name+" lunar observation file",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'summary' , "Lunar observation file",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'keywords' , "GSICS, satellites, lunar, moon, observation, visible",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'references' , "TBD",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'institution' , stGprc.sInstitute,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'license' , stGprc.sLicence,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'creator_name' , stGprc.sCreator_Name,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'creator_email' , stGprc.sCreator_Email,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'creator_url' , stGprc.sCreator_Url,/CHAR,/GLOBAL ;NCDF_ATTPUT,iCdfid,'naming_authority' , stGprc.sNaming_Authority,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'instrument' , sSatGlb+" "+stMeta.sInst_Name,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'instrument_wmo_code' , stMeta.sSatInst_Wmo_Code,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'data_source' , stMeta.sData_Source,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'date_created' , sDatetime_Now,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'date_modified' , sDatetime_Now,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'history' , "TBD",/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'id' , sNcdfFile,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'wmo_data_category' , iWmo_Data_Category,/SHORT,/GLOBAL NCDF_ATTPUT,iCdfid,'wmo_international_data_subcategory', $ iWmo_International_Data_Subcategory,/SHORT,/GLOBAL NCDF_ATTPUT,iCdfid,'processing_level' , stMeta.sVersion,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'doc_url' , stMeta.sDoc_Url,/CHAR,/GLOBAL NCDF_ATTPUT,iCdfid,'doc_doi' , stMeta.sDoc_Doi,/CHAR,/GLOBAL ; channel_name (Compulsory) varid=NCDF_VARDEF(iCdfid,'channel_name',[iChlenid,iChid],/CHAR) NCDF_ATTPUT,iCdfid,varid,'standard_name', 'sensor_band_identifier',/CHAR NCDF_ATTPUT,iCdfid,varid,'long_name', 'channel identifier',/CHAR ; date (Compulsory) varid=NCDF_VARDEF(iCdfid,'date',[iTid],/DOUBLE) NCDF_ATTPUT,iCdfid,varid,'standard_name', 'time',/CHAR NCDF_ATTPUT,iCdfid,varid,'long_name', 'time of lunar observation',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', 'seconds since 1970-01-01T00:00:00Z',/CHAR NCDF_ATTPUT,iCdfid,varid,'calendar', 'gregorian',/CHAR ; sat_pos (Compulsory) varid=NCDF_VARDEF(iCdfid,'sat_pos',[iStposid],/DOUBLE) NCDF_ATTPUT,iCdfid,varid,'long_name', 'satellite position x y z in sat_pos_ref',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', 'km',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0.00,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'valid_max', 1000000000000.00,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'_FillValue', d_FillValue,/DOUBLE ; sat_pos_ref (Compulsory) varid=NCDF_VARDEF(iCdfid,'sat_pos_ref',[iStrefid],/CHAR) NCDF_ATTPUT,iCdfid,varid,'long_name', 'reference frame of satellite position',/CHAR ; irr_obs (Compulsory) varid=NCDF_VARDEF(iCdfid,'irr_obs',[iChid],/DOUBLE) NCDF_ATTPUT,iCdfid,varid,'long_name', 'observed lunar irradiance',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', 'W m-2 um-1',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'valid_max', 1000000.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'_FillValue', d_FillValue,/DOUBLE ; pix_solid_ang (Additional) varid=NCDF_VARDEF(iCdfid,'pix_solid_ang',[iChid],/DOUBLE) NCDF_ATTPUT,iCdfid,varid,'long_name', 'pixel solid angle',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', 'sr',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'valid_max', 1.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'_FillValue', d_FillValue,/DOUBLE ; ovrsamp_fa (Additional) varid=NCDF_VARDEF(iCdfid,'ovrsamp_fa',[iChid],/DOUBLE) NCDF_ATTPUT,iCdfid,varid,'long_name', 'oversampling factor',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', '1',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'valid_max', 999.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'_FillValue', d_FillValue,/DOUBLE ; dc_obs (Additional) varid=NCDF_VARDEF(iCdfid,'dc_obs',[iChid],/LONG) NCDF_ATTPUT,iCdfid,varid,'long_name', 'integrated digital counts of lunar obserevation',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', '1',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0,/LONG NCDF_ATTPUT,iCdfid,varid,'valid_max', 2147483647,/LONG NCDF_ATTPUT,iCdfid,varid,'_FillValue', i_FillValue,/LONG ; dc_obs_offset (Additional) varid=NCDF_VARDEF(iCdfid,'dc_obs_offset',[iChid],/DOUBLE) NCDF_ATTPUT,iCdfid,varid,'long_name', 'averaged digital counts offset of deep space',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', '1',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'valid_max', 1000000.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'_FillValue', d_FillValue,/DOUBLE ; moon_pix_num (Additional) varid=NCDF_VARDEF(iCdfid,'moon_pix_num',[iChid],/LONG) NCDF_ATTPUT,iCdfid,varid,'long_name', 'number of moon pixels',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', '1',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0,/LONG NCDF_ATTPUT,iCdfid,varid,'valid_max', 1000000,/LONG NCDF_ATTPUT,iCdfid,varid,'_FillValue', i_FillValue,/LONG ; moon_pix_thld (Imagette) varid=NCDF_VARDEF(iCdfid,'moon_pix_thld',[iChid],/LONG) NCDF_ATTPUT,iCdfid,varid,'long_name', 'digital counts threshold for moon masking',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', '1',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0,/LONG NCDF_ATTPUT,iCdfid,varid,'valid_max', 1000000,/LONG NCDF_ATTPUT,iCdfid,varid,'_FillValue', i_FillValue,/LONG ; rad_obs_imgt (Imagette) varid=NCDF_VARDEF(iCdfid,'rad_obs_imgt',[iChid,iColid,iRowid],/DOUBLE ) NCDF_ATTPUT,iCdfid,varid,'long_name', 'observed lunar radiance imagette',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', 'W sr-1 m-2 um-1',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', -998.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'valid_max', 1000000.,/DOUBLE NCDF_ATTPUT,iCdfid,varid,'_FillValue', d_FillValue,/DOUBLE ; dc_obs_imgt (Imagette) varid=NCDF_VARDEF(iCdfid,'dc_obs_imgt',[iChid,iColid,iRowid],/LONG) NCDF_ATTPUT,iCdfid,varid,'long_name', 'observed moon digital counts imagette',/CHAR NCDF_ATTPUT,iCdfid,varid,'units', '1',/CHAR NCDF_ATTPUT,iCdfid,varid,'valid_min', 0,/LONG NCDF_ATTPUT,iCdfid,varid,'valid_max', 1000000,/LONG NCDF_ATTPUT,iCdfid,varid,'_FillValue', i_FillValue,/LONG ; Put the file into data mode NCDF_CONTROL,iCdfid, /ENDEF ; Write out variables ; Compulsory NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'channel_name' ),stMeta.sChan_Name[0:iChan_Num-1] NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'date' ),dDate NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'sat_pos' ),dSat_Pos NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'sat_pos_ref' ),sSat_Pos_Ref NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'irr_obs' ),dIrr_Obs ; Additional NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'pix_solid_ang'),dPix_Solid_Ang NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'ovrsamp_fa' ),dOvrsamp_Fa NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'dc_obs' ),iDc_Obs NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'dc_obs_offset'),dDc_Obs_Offset NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'moon_pix_num' ),iMoon_Pix_Num ; Imagette NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'moon_pix_thld'),iMoon_Pix_Thld NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'rad_obs_imgt' ),dRad_Obs_Imgt NCDF_VARPUT,iCdfid,NCDF_VARID(iCdfid,'dc_obs_imgt' ),iDc_Obs_Imgt ; close netCDF NCDF_CLOSE, iCdfid ; Close the NetCDF file. return, ; whatever you want to return END