function gen_labels,min,max,nt,cneg,cpos,nprec=nprec ; ; The strings cpos and cneg will be appended at the end of the number values. ; If the value is zero, nothing will be appended to the label string. If the ; strings cpos and/or cneg are of length zero, the label strings will appear ; without anything appended and the negative values will be -10 etc. ; Note: A special case exists for min>=max. For this case, max will be set to ; max + 360 and values greater than 180 will be treated as negative. ; labels=strarr(nt+1) ;if (strlen(cpos) GT 0) then sp=' ' else sp='' ;if (strlen(cneg) GT 0) then sn=' ' else sn='' if n_elements(nprec) EQ 0 then nprec=0 sp='' sn='' if (min GE max) then begin dateflag=1 max=max+360 endif else begin if (max GT 180) AND (min LT 180) then dateflag=1 else dateflag=0 endelse for i=0,nt do begin x=min + i*(max-min)/nt if (dateflag EQ 1) AND (strlen(cneg) EQ 0) AND (strlen(cpos) EQ 0) then begin if (x GT 180) then x=x-360 endif if (abs(x) LT 10) then begin n=0; endif else begin n=floor(alog10(abs(x))) endelse if (strlen(cneg) GT 0) AND (x GT 180) then x=x-360 if (x LT 0) then begin if (strlen(cneg) GT 0) then begin if (nprec EQ 0) then begin fmt=string(n+1,format='("(i",i1,",a,a)")') endif else begin fmt=string(n+2+nprec,nprec,format='("(f",i2.2,".",i1,",a,a)")') endelse labels(i)=string(-x,sn,cneg,format=fmt) if (x EQ -180) AND (dateflag EQ 1) then labels(i)='-180' endif else begin if (nprec EQ 0) then begin fmt=string(n+2,format='("(i",i1,",a,a)")') endif else begin fmt=string(n+3+nprec,nprec,format='("(f",i2.2,".",i1,",a,a)")') endelse labels(i)=string(x,format=fmt) endelse endif if (x EQ 0) then begin if (cpos(0) EQ 'n' OR cpos(0) EQ 'N') then labels(i)='EQ' else labels(i)='0' endif if (x GT 0) then begin if (nprec EQ 0) then begin fmt=string(n+1,format='("(i",i1,",a,a)")') endif else begin fmt=string(n+2+nprec,nprec,format='("(f",i2.2,".",i1,",a,a)")') endelse labels(i)=string(x,sp,cpos,format=fmt) if (x EQ 180) AND (dateflag EQ 1) then labels(i)='180' endif endfor return,labels end