def footprint (tel, reportfile=None, equfile=None, galfile=None, run=None, day=None, before=False) : """ Draw footprint of survey args: tel: telescope brief code reportfile: report text file, default is current datetime, set empty string will suppress output, same for figure file equfile: output file name for Equatorial System galfile: output file name for Galactic System run: code of run to be marked, usually as yyyymm format day: mjd of date to be marked, must be present with run before: draw covered bofore specified run or day """ # set default output file dt = time.strftime("%Y%m%d%H%M%S") if reportfile is None : reportfile = "{tel}/obsed/footprint/report.{dt}.txt".format(tel=tel, dt=dt) if equfile is None : equfile = "{tel}/obsed/footprint/equ.{dt}.png".format(tel=tel, dt=dt) if galfile is None : galfile = "{tel}/obsed/footprint/gal.{dt}.png".format(tel=tel, dt=dt) # load fields configure file plans = schdutil.load_expplan(tel) fields = schdutil.load_field(tel) plancode = list(plans.keys()) plancode.sort() # find all obsed file obsedlist = schdutil.ls_files("{tel}/obsed/*/obsed.J*.lst".format(tel=tel)) if run is not None and day is not None : marklist = schdutil.ls_files("{tel}/obsed/{run}/obsed.J{day}.lst".format(tel=tel, run=run, day=day)) marktext = "J{day}".format(run=run, day=day) elif run is not None and day is None : marklist = schdutil.ls_files("{tel}/obsed/{run}/obsed.J*.lst".format(tel=tel, run=run)) marktext = "{run}".format(run=run, day=day) else : marklist = [] marktext = None if before : maxmark = max(marklist) obsedlist = [f for f in obsedlist if f <= maxmark] schdutil.load_obsed(fields, obsedlist, plans, marklist) # generate a text report if reportfile != "" : with open(reportfile, "w") as rep : for f in fields.values() : rep.write(("{0} {1:1d} ").format(f, f.tag)) for p in plancode : rep.write(" {:>4.1f}".format(f.factor[p])) for p in plancode : rep.write(" {:>4.1f}".format(f.mark[p])) rep.write("\n") #rep.close() # draw Equatorial System plt.rcParams['figure.figsize'] = 16,10 # extract ra/dec/gl/gb from fields, by different tag # use np.where can do this better, but I am lazy ra0 = [f.ra for f in fields.values() if f.tag == 0] de0 = [f.de for f in fields.values() if f.tag == 0] gl0 = [f.gl for f in fields.values() if f.tag == 0] gb0 = [f.gb for f in fields.values() if f.tag == 0] n0 = len(ra0) ra1 = [f.ra for f in fields.values() if f.tag == 1 or f.tag == 2] de1 = [f.de for f in fields.values() if f.tag == 1 or f.tag == 2] gl1 = [f.gl for f in fields.values() if f.tag == 1 or f.tag == 2] gb1 = [f.gb for f in fields.values() if f.tag == 1 or f.tag == 2] n1 = len(ra1) ra3 = [f.ra for f in fields.values() if f.tag == 3] de3 = [f.de for f in fields.values() if f.tag == 3] gl3 = [f.gl for f in fields.values() if f.tag == 3] gb3 = [f.gb for f in fields.values() if f.tag == 3] n3 = len(ra3) if equfile != "" : equf = moll(lat_range=(-5,88)) equf.grid(lat_lab_lon=0, lon_lab_lat=-5, lat_step=10) equf.scatter(ra0, de0, "k,", label="Future {}".format(n0)) equf.scatter(ra1, de1, "bs", label="Done {}".format(n1+n3)) if marktext is not None : equf.scatter(ra3, de3, "rs", label="{} {}".format(marktext, n3)) plt.legend() plt.title("{tel} Footprint in Equatorial System".format(tel=tel)) plt.savefig(equfile) plt.close() if galfile != "" : galf = moll() galf.grid(lat_lab_lon=0, lon_lab_lat=-5) galf.scatter(gl0, gb0, "k,", label="Future {}".format(n0)) galf.scatter(gl1, gb1, "bs", label="Done {}".format(n1+n3)) if marktext is not None : galf.scatter(gl3, gb3, "rs", label="{} {}".format(marktext, n3)) plt.legend() plt.title("{tel} Footprint in Galactic System".format(tel=tel)) plt.savefig(galfile) plt.close()
def plotmap (ra, de, tag, title="", epsfile=None, pngfile=None, spos=None, mpos=None, zenith=None, xcolormark=None, xlabel=None) : """ Plot a map about fields, different tag have different color and marker. args: ra: ndarray of ra de: ndarray of dec tag: ndarray of tag title: title of map epsfile: eps filename to save, if None, do not save as eps pngfile: png filename to save, if None, do not save as png mpos: tuple of ra and dec of moon position, if none, do not mark spos: tuple of ra and dec of sun position, if none, do not mark zenith: tuple of ra and dec of zenith, if none, do not mark xcolormark: dict of color and mark for different tag, if none, use default xlabel: dict of labels for each tag, if none, use default """ # handling default arguments if xcolormark is None : xcolormark = { 0x00:"k,", # unobserved and not planed 0x01:"k+", # partly observed and not planned 0x02:"go", # finished 0x03:"rs", # planed in this night 0x04:"m+", # candidate0 0x05:"m+", # candidate1 0x07:"bs", # latest added 0x10:"y,", # Sun or Moon neighbourhood 0x11:"y+", # 0x12:"yo", # 0x1F:"b,", # skiped } if xlabel is None : xlabel = { 0x00:"Unobserved", # 00000 0x01:"Partly obsed", # 00001 0x02:"Finished", # 00010 0x03:"Tonight", # 00011 0x04:"Candidate", # 00100 0x05: None, # 00101 0x07:"New Selection",# 00111 0x10:"Near Sun/Moon",# 10000 0x11:"Near Sun/Moon",# 10001 0x12:"Near Sun/Moon",# 10010 0x1F:"Skiped", # 11111 } # plot equf = moll(lat_range=(-5,88), xsize=180, ysize=90, lon_center=30.0) plt.figure(figsize=(18,10)) equf.grid(lat_lab_lon=240, lon_lab_lat=-5, lat_step=10) for t in set(tag): ix = np.where(tag == t) equf.scatter(ra[ix], de[ix], xcolormark[t], label=xlabel[t]) if spos is not None : x, y = equf.project(spos[0], spos[1]) plt.plot(x, y, "ro", markersize=10.0, label="Sun {ra:5.1f} {de:5.1f}".format(ra=spos[0], de=spos[1])) if mpos is not None : x, y = equf.project(mpos[0], mpos[1]) plt.plot(x, y, "rD", markersize=10.0, label="Moon {ra:5.1f} {de:5.1f}".format(ra=mpos[0], de=mpos[1])) if zenith is not None : x, y = equf.project(zenith[0], zenith[1]) plt.plot(x, y, "r^", markersize=10.0, label="Zenith {ra:5.1f} {de:5.1f}".format(ra=zenith[0], de=zenith[1])) plt.legend() plt.title("{title} Observation Plan".format(title=title)) if epsfile is not None : plt.savefig(epsfile) if pngfile is not None : plt.savefig(pngfile) plt.close()