;--I root = '/data/spectroscopy/smass/' date = '2022-05-17' dir=root+date+'/' csv = 'smass-'+date+'.csv' readcol, dir+csv, Number,Name,Designation,VNIR,file,plot,refHtml,refName,Note,obsDate, $ format='(L,A,A,A,A,A,A,A,A,A)', /Silent, delimiter=',' nbSMASS = n_elements(number) VNIR=strTrim(VNIR,2) file=strTrim(file,2) name=strTrim(name,2) designation=strTrim(Designation,2) url = 'http://smass.mit.edu/' file_mkdir, dir+'Vis' file_mkdir, dir+'Vis+NIR' file_mkdir, dir+'NIR' for kSSO=0, nbSMASS-1 do begin ;--- define local name ;old version - my names ;locName='' ;if not strCmp(number[kSSO],'') then locName += string(number[kSSO],format='(I06)')+'-' ;if not strCmp(Name[kSSO],'0') then locName += name[kSSO] $ ; else locName += Designation[kSSO] ;split=strSplit(locName,' ',/Extract, count=nbField) ;if nbField gt 1 then locName=split[0]+split[1] ; ; new version, we keep SMASS name split = strSplit( file[kSSO], '/', /Extract ) locName = split[-1] ;--- take care of multiple observations ;if file_test(dir+VNIR[kSSO]+'/'+locName) then begin ; notOk=0 ; kV=1 ; while notOk eq 0 do begin ; kV++ ; newName = locName+'-'+string(kV,format='(I02)') ; if not file_test(dir+VNIR[kSSO]+'/'+newName+'.txt') then begin ; locName=newName ; notOk=1 ; endif ; endwhile ;endif ;--- Correct missing .txt at the end of SMASS URL split=strSplit(file[kSSO],'.',/Extract) if not strCmp( split[-1],'txt',3,/Fold_Case) then file[kSSO]+='.txt' ;--- Download data print, kSSO, nbSMASS, locName, format='(I4,"/",I4,3x,A-50)' ; print, 'curl -s "'+url+file[kSSO]+'" > '+dir+VNIR[kSSO]+'/'+locName+'.txt' CATCH, missing if missing ne 0 then begin goto, j2Next CATCH, /CANCEL endif res=wget(url+file[kSSO], file=dir+VNIR[kSSO]+'/'+locName) ;stop j2Next: endfor ; if getNIR eq 1 then begin ; selNIR = where( strCmp(VNIR,'NIR'), nbNIR ) ; for kNIR=0, nbNIR-1 do begin ; ;; split = strsplit(sso[selNIR[kNIR]].name,' ',/extract, count=nbField) ;; if nbField eq 1 then name = sso[selNIR[kNIR]].name else $ ;; name = split[0]+'_'+split[1] ; ; ; print, 'curl -s "'+url+file[selNIR[kNIR]]+'" > '+dir+'NIR/'+locName+'.txt' ;; spawn, 'curl -s "'+url+file[selNIR[kNIR]]+'" > '+dir+'NIR/'+name+'.txt' ; ; endfor ; endif end ;- if getVNIR eq 1 then begin ;- selVISNIR = where( strCmp(VNIR,'Vis+NIR'), nbVISNIR ) ;- for kVISNIR=0, nbVISNIR-1 do begin ;- ;- split = strsplit(sso[selVISNIR[kVISNIR]].name,' ',/extract, count=nbField) ;- if nbField eq 1 then name = sso[selVISNIR[kVISNIR]].name else $ ;- name = split[0]+'_'+split[1] ;- spawn, 'curl -s "'+sso[selVISNIR[kVISNIR]].link+'" > '+dir+'VisNIR/'+name+'.txt' ;- ;- endfor ;- endif ;- ;- if getVis eq 1 then begin ;- selVIS = where( strCmp(VNIR,'Vis'), nbVIS ) ;- for kVIS=0, nbVIS-1 do begin ;- ;- split = strsplit(sso[selVIS[kVIS]].name,' ',/extract, count=nbField) ;- if nbField eq 1 then name = sso[selVIS[kVIS]].name else $ ;- name = split[0]+'_'+split[1] ;- spawn, 'curl -s "'+sso[selVIS[kVIS]].link+'" > '+dir+'Vis/'+name+'.txt' ;- ;- endfor ;- endif ;- ;- ;- ;- ;- ;- ;- ;- ;- ;- ;--I ;-; dir = '/home/bcarry/data/mining/smass/' ;-; cata = 'spectracatalog-2016-05-18.csv' ;-; csv = 'smass.mit.edu-2016-05-19.csv' ;- ;- ;--II--Read list ;- readcol, dir+cata, delimiter=',', num, name, des, vis, nir, visnir, format='(I,A,A,A,A,A)',/Silent ;- nbSmass = n_elements( des ) ;-; print, nbSmass ;- ;- ;--III--Read HTML ;- openr, id, dir+csv, /get_lun ;- ;- ;- line='' ;- kL=0L ;- ;- spawn, 'wc '+dir+csv+" -l|awk '{print $1}'", nbLine ;- sso = replicate({num:0L, name:'', des:'', wave:'',link:'', ref:'', ep:''},nbLine) ;- ;- ;- while ~eof(id) do begin ;- ;- readf, id, line ;- split = strSplit( line, ',', /Extract, count=nbField ) ;- ;- ;- case nbField of ;- ;- 9: begin ;- pos = strpos( split[0], ')' ) ;- if pos ne -1 then begin ;- sub = strSplit( split[0],'()',/Extract) ;- sso[kL].num = round(float(sub[1])) ;- sso[kL].name= strTrim(split[1],2) ;- endif else begin ;- sso[kL].num = sso[kL-1].num ;- sso[kL].name= sso[kL-1].name ;- sso[kL].des = sso[kL-1].des ;- endelse ;- ;- sso[kL].wave = strTrim( split[2],2) ;- sso[kL].link = strTrim( split[3],2) ;- sso[kL].ref = strTrim( split[7],2) ;- sso[kL].ep = strTrim( split[8],2) ;- end ;- ;- 7: begin ;- pos = strpos( split[0], ')' ) ;- if pos ne -1 then begin ;- sub = strSplit( split[0],'()',/Extract) ;- sso[kL].num = round(float(sub[1])) ;- sso[kL].name= strTrim(split[1],2) ;- endif else begin ;- sso[kL].num = sso[kL-1].num ;- sso[kL].name= sso[kL-1].name ;- sso[kL].des = sso[kL-1].des ;- endelse ;- ;- sso[kL].wave = strTrim( split[2],2) ;- sso[kL].link = strTrim( split[3],2) ;- sso[kL].ref = strTrim( split[5],2) ;- sso[kL].ep = strTrim( split[6],2) ;- end ;- ;- ;- 10: begin ;- pos = strpos( split[0], ')' ) ;- if pos ne -1 or strcmp( strtrim(split[0],2),'0') then begin ;- ;- if pos ne -1 then begin ;- sub = strSplit( split[0],'()',/Extract) ;- sso[kL].num = round(float(sub[1])) ;- endif ;- sso[kL].name= strTrim(split[1],2) ;- sso[kL].des = strTrim(split[2],2) ;- endif else begin ;- sso[kL].num = sso[kL-1].num ;- sso[kL].name= sso[kL-1].name ;- sso[kL].des = sso[kL-1].des ;- endelse ;- ;- sso[kL].wave = strTrim( split[3],2) ;- sso[kL].link = strTrim( split[4],2) ;- sso[kL].ref = strTrim( split[8],2) ;- sso[kL].ep = strTrim( split[9],2) ;- if strcmp( strtrim(split[0]),'' ) then stop ;- end ;- ;- 8: begin ;- pos = strpos( split[0], ')' ) ;- if pos ne -1 or strcmp( strtrim(split[0],2),'0') then begin ;- ;- if pos ne -1 then begin ;- sub = strSplit( split[0],'()',/Extract) ;- sso[kL].num = round(float(sub[1])) ;- endif ;- sso[kL].name= strTrim(split[1],2) ;- sso[kL].des = strTrim(split[2],2) ;- endif else begin ;- sso[kL].num = sso[kL-1].num ;- sso[kL].name= sso[kL-1].name ;- sso[kL].des = sso[kL-1].des ;- endelse ;- ;- sso[kL].wave = strTrim( split[3],2) ;- sso[kL].link = strTrim( split[4],2) ;- sso[kL].ref = strTrim( split[6],2) ;- sso[kL].ep = strTrim( split[7],2) ;- ;- end ;- ;- 11: begin ;- pos = strpos( split[0], ')' ) ;- if pos ne -1 or strcmp( strtrim(split[0],2),'0') then begin ;- ;- if pos ne -1 then begin ;- sub = strSplit( split[0],'()',/Extract) ;- sso[kL].num = round(float(sub[1])) ;- endif ;- sso[kL].name= strTrim(split[1],2) ;- sso[kL].des = strTrim(split[2],2) ;- endif else begin ;- sso[kL].num = sso[kL-1].num ;- sso[kL].name= sso[kL-1].name ;- sso[kL].des = sso[kL-1].des ;- endelse ;- ;- sso[kL].wave = strTrim( split[3],2) ;- sso[kL].link = strTrim( split[4],2) ;- sso[kL].ref = strTrim( split[8],2) ;- sso[kL].ep = strTrim( split[10],2) ;- ;- end ;- ;- else: begin ;- end ;- endcase ;- ;- ;- kL++ ;- endwhile ;- ;- ;- close, id ;- free_lun, id ;- ;- ;- sel = where( strcmp(sso.name, '') ) ;- sso[sel].name = sso[sel].des ;- ;- ;- forprint, sso.num, sso.name, sso.wave, sso.ref, sso.link, textout=dir+'info.smass.csv', $ ;- format='(I6," , ",A-20," , ",A-7," , ",A-8," , ",A-60)', $ ;- comment='Number, Name, Waverange, Reference, Link', /Silent ;- ;- ;- if getNIR eq 1 then begin ;- selNIR = where( strCmp(sso.wave,'NIR'), nbNIR ) ;- for kNIR=0, nbNIR-1 do begin ;- ;- split = strsplit(sso[selNIR[kNIR]].name,' ',/extract, count=nbField) ;- if nbField eq 1 then name = sso[selNIR[kNIR]].name else $ ;- name = split[0]+'_'+split[1] ;- spawn, 'curl -s "'+sso[selNIR[kNIR]].link+'" > '+dir+'NIR/'+name+'.txt' ;- ;- endfor ;- endif ;- if getVNIR eq 1 then begin ;- selVISNIR = where( strCmp(sso.wave,'Vis+NIR'), nbVISNIR ) ;- for kVISNIR=0, nbVISNIR-1 do begin ;- ;- split = strsplit(sso[selVISNIR[kVISNIR]].name,' ',/extract, count=nbField) ;- if nbField eq 1 then name = sso[selVISNIR[kVISNIR]].name else $ ;- name = split[0]+'_'+split[1] ;- spawn, 'curl -s "'+sso[selVISNIR[kVISNIR]].link+'" > '+dir+'VisNIR/'+name+'.txt' ;- ;- endfor ;- endif ;- ;- if getVis eq 1 then begin ;- selVIS = where( strCmp(sso.wave,'Vis'), nbVIS ) ;- for kVIS=0, nbVIS-1 do begin ;- ;- split = strsplit(sso[selVIS[kVIS]].name,' ',/extract, count=nbField) ;- if nbField eq 1 then name = sso[selVIS[kVIS]].name else $ ;- name = split[0]+'_'+split[1] ;- spawn, 'curl -s "'+sso[selVIS[kVIS]].link+'" > '+dir+'Vis/'+name+'.txt' ;- ;- endfor ;- endif ;- ;- ;-end