Exemplo n.º 1
0
    def save(self, fn):

        d = dict(orders=self.orders, wvl_list=[], x_list=[], y_list=[])

        for o in self.orders:
            zd = self.zdata[o]
            d["wvl_list"].append(zd.wvl)
            d["x_list"].append(zd.x)
            d["y_list"].append(zd.y)

        from json_helper import json_dump
        json_dump(d, open(fn, "w"))
Exemplo n.º 2
0
    def save(self, fn):

        d = dict(orders=self.orders,
                 wvl_list=[],
                 x_list=[],
                 y_list=[])

        for o in self.orders:
            zd = self.zdata[o]
            d["wvl_list"].append(zd.wvl)
            d["x_list"].append(zd.x)
            d["y_list"].append(zd.y)

        from json_helper import json_dump
        json_dump(d, open(fn, "w"))
Exemplo n.º 3
0
    def save(self, mastername, masterhdu=None):

        fn, ext = os.path.splitext(mastername)
        dict_to_save = dict()
        for k, d in self.items():
            if hasattr(d, "shape") and (d.shape == masterhdu.data.shape):
                if d.dtype == bool:
                    d = d.astype("i8")
                if masterhdu is not None:
                    hdu = pyfits.PrimaryHDU(header=masterhdu.header, data=d)
                else:
                    hdu = pyfits.PrimaryHDU(data=d)
                fn0 = "".join([fn, ".", k, ".fits"])
                hdu.writeto(fn0, clobber=True)
                dict_to_save[k + ".fits"] = os.path.basename(fn0)
            else:
                dict_to_save[k] = d
        if dict_to_save:
            json_dump(dict_to_save, open(mastername, "w"))
Exemplo n.º 4
0
    def save(self, mastername, masterhdu=None):

        fn, ext = os.path.splitext(mastername)
        dict_to_save = dict()
        for k, d in self.items():
            if hasattr(d, "shape") and (d.shape == masterhdu.data.shape):
                if d.dtype == bool:
                    d = d.astype("i8")
                if masterhdu is not None:
                    hdu = pyfits.PrimaryHDU(header=masterhdu.header,
                                            data=d)
                else:
                    hdu = pyfits.PrimaryHDU(data=d)
                fn0 = "".join([fn, ".", k, ".fits"])
                hdu.writeto(fn0, clobber=True)
                dict_to_save[k+".fits"] = os.path.basename(fn0)
            else:
                dict_to_save[k] = d
        if dict_to_save:
            json_dump(dict_to_save, open(mastername, "w"))
Exemplo n.º 5
0
    d = dict(wvl_list=[],
             ref_indices_list=[],
             pixpos_list=[],
             orders=orders,
             ref_name=ref_name)

    for wvl, s, _ in zip(wvl_sol, s_list, ddd_list):
        wvl_reference_filtered, matched_indices, centroids = _

        d["wvl_list"].append(wvl_reference_filtered)
        d["ref_indices_list"].append(matched_indices)
        d["pixpos_list"].append(centroids)

    from json_helper import json_dump
    json_dump(
        d,
        open("%s_IGRINS_identified_%s_%s.json" % (REF_TYPE, band, utdate),
             "w"))

    for wvl, s, _ in zip(wvl_sol, s_list, ddd_list):
        wvl_reference_filtered, matched_indices, centroids = _
        fig = figure()
        ax = fig.add_subplot(111)
        draw_one(wvl, s, wvl_reference_filtered, centroids, ax=ax)

if 0:

    json.dump([[(s[0], list(s[1])) for s in ss] for ss, d in matched_list2],
              open("thar_identified_%s_%s.json" % (band, date), "w"))

    i = 20
    clf()
Exemplo n.º 6
0
    if 1:
        band = "K"
        utdate = "20140525"
        import json
        s_list = json.load(open("arc_spec_sky_%s_%s.json" % (band, utdate)))
        wvl_sol = json.load(open("wvl_sol_phase0_%s_%s.json" \
                                 % (band, utdate)))
        bootstrap_name = "hitran_bootstrap_K_20140316.json"
        bootstrap = json.load(open(bootstrap_name))

        sol_sol = reidentify(wvl_sol, s_list, bootstrap)

        from json_helper import json_dump
        if 1:
            json_dump(sol_sol,
                      open("hitran_reidentified_%s_%s.json" % (band, utdate),
                           "w"),
                      )


if 0:
        if 0:
            import matplotlib.pyplot as plt
            plt.clf()
            ax = plt.subplot(311)
            ax.plot(wvl_igr, s_igr_m)
            ax.plot(wvl1, ss)

            for ll, sol in zip(hitrans_detected[i], sol_list):
                xx = sol[0][0]+np.array(ll)-ll[0]
                ax.vlines(xx, ymin=0, ymax=sol[0][2])
                ax.hlines(sol[0][2]*0.5,
Exemplo n.º 7
0
 def store(self, fn, masterhdu):
     json_dump(self, open(fn, "w"))
Exemplo n.º 8
0
 def store(self, fn, masterhdu=None):
     json_dump(self, open(fn, "w"))
Exemplo n.º 9
0
    if 1:
        band = "K"
        utdate = "20140525"
        import json
        s_list = json.load(open("arc_spec_sky_%s_%s.json" % (band, utdate)))
        wvl_sol = json.load(open("wvl_sol_phase0_%s_%s.json" \
                                 % (band, utdate)))
        bootstrap_name = "hitran_bootstrap_K_20140316.json"
        bootstrap = json.load(open(bootstrap_name))

        sol_sol = reidentify(wvl_sol, s_list, bootstrap)

        from json_helper import json_dump
        if 1:
            json_dump(
                sol_sol,
                open("hitran_reidentified_%s_%s.json" % (band, utdate), "w"),
            )

if 0:
    if 0:
        import matplotlib.pyplot as plt
        plt.clf()
        ax = plt.subplot(311)
        ax.plot(wvl_igr, s_igr_m)
        ax.plot(wvl1, ss)

        for ll, sol in zip(hitrans_detected[i], sol_list):
            xx = sol[0][0] + np.array(ll) - ll[0]
            ax.vlines(xx, ymin=0, ymax=sol[0][2])
            ax.hlines(sol[0][2] * 0.5,
                      xmin=xx - sol[0][1],
Exemplo n.º 10
0
        _ = ddd(wvl, s, wvl_reference)
        ddd_list.append(_)

    d = dict(wvl_list=[], ref_indices_list=[], pixpos_list=[],
             orders=orders,
             ref_name=ref_name)

    for wvl, s, _ in zip(wvl_sol, s_list, ddd_list):
        wvl_reference_filtered, matched_indices, centroids = _

        d["wvl_list"].append(wvl_reference_filtered)
        d["ref_indices_list"].append(matched_indices)
        d["pixpos_list"].append(centroids)

    from json_helper import json_dump
    json_dump(d, open("%s_IGRINS_identified_%s_%s.json" % (REF_TYPE, band, utdate),"w"))

    for wvl, s, _ in zip(wvl_sol, s_list, ddd_list):
        wvl_reference_filtered, matched_indices, centroids = _
        fig = figure()
        ax = fig.add_subplot(111)
        draw_one(wvl, s, wvl_reference_filtered, centroids, ax=ax)




if 0:

    json.dump([[(s[0], list(s[1])) for s in ss] for ss, d in matched_list2],
              open("thar_identified_%s_%s.json" % (band, date),"w"))
Exemplo n.º 11
0
 def save(self, fn):
     from json_helper import json_dump
     json_dump(self.data, open(fn, "w"))
Exemplo n.º 12
0
 def save(self, fn):
     from json_helper import json_dump
     json_dump(self.data, open(fn,"w"))