; ---------------------------------------------------------------------- ; Choose best AVP files for date of exposure. ; pro nsxng_choose_best_AVP, IMG, nsxdir, UseAVP ; common nsx maxnn = 100 jds = dblarr(maxnn) ; Available files. UseAVP = '2017-11-02' ;> fill jds with the Julian Date of $nsxdir/cal/AVP.yyyy-mm-dd.info ;misc_delete_file("ncba.temp"); ;sprintf(wrd,"ls -1d %scal/AVP.*.info > ncba.temp",nsxdir) ;system(wrd) ;infu = fopen_read("ncba.temp") ;nn=0 ;while (fgetline(line,infu)) { ; ii = cindex(line,"AVP.") ; substrcpy_terminate(line,ii+4,ii+13,wrd,0); strcat(wrd,"T00:00:00.000") ; jds[nn] = misc_zulu_to_julian(wrd) ; ++nn ; if (nn > maxnn-3) { printf("***error: ncbA: too many AVP.*.info files in '%scal'.\n",nsxdir); exit(1); } ;} ;fclose(infu) ;misc_delete_file("ncba.temp") lines = FILE_SEARCH(nsxdir + 'cal/AVP.*.info', count = nn) for ii = 0, nn-1 do jds[ii] = misc_zulu_to_julian(strmid(file_basename(lines[ii], '.info'), 4,10)) jds = jds[0:nn-1] ;first_jd =("2017-11-02T00:00:00.000") jd = IMG.jd ;if (jd < first_jd) jd = first_jd ;losep=9.e+20; loii=-1 ;for (ii=0; ii -1) { misc_julian_to_zulu( jds[loii], UseAVP ); ;UseAVP[10]='\0'; } temp = min( abs(jd - jds), loii) UseAVP = strmid(file_basename(lines[loii], '.info'), 4,10) print, format='("UT date of exposure is ",A,".")',IMG.utshut print, format='("Best AVP file match ",A,".")',UseAVP end