コード例 #1
0
ファイル: demo_loadsave.py プロジェクト: mniehus/pyrate
def create_save_load_compare(name, mycreate, mycompare):
    o = mycreate()
    o_ser = Serializer(o)
    o_ser.save_yaml(serialization_path + name + ".yaml")
    o_ser.save_json(serialization_path + name + ".json")
    del o_ser
    o2_json = Deserializer.load_json(serialization_path + name + ".json", True,
                                     True)
    o2_yaml = Deserializer.load_yaml(serialization_path + name + ".yaml", True,
                                     True)
    print("compare json")
    mycomp_json = mycompare(o, o2_json)
    print("compare yaml")
    mycomp_yaml = mycompare(o, o2_yaml)
    return mycomp_json and mycomp_yaml
コード例 #2
0
ファイル: demo_rainbow.py プロジェクト: mvsantosdev/pyrate
                ("surf4", {}),
                ("image", {})])]

raysdict = {
     "radius": dropletradius*0.05,
     "starty": dropletradius*0.9,
     "anglex": -12.*degree,
     "raster": raster.MeridionalFan()
     }

r_red = raytrace(s, sysseq, 11, raysdict, wave=wave_red)[0]
r_blue = raytrace(s, sysseq, 11, raysdict, wave=wave_blue)[0]

draw(s, [(r_red, "red"), (r_blue, "blue")])

system_dump = Serializer(s).serialization
system_gui_toplevel = UIInterfaceClassWithOptimizableVariables(
        s.elements["droplet"].surfaces["surf4"].shape).query_for_dictionary()

#pprint(system_gui_toplevel)
#pprint(system_dump)

fp = open("rainbow.yaml", "wt")
yaml.dump(system_dump, fp)
fp.close()


fp = open("rainbow.json", "wt")
json.dump(system_dump, fp, indent=4)
fp.close()
コード例 #3
0
ファイル: demo_doublegauss.py プロジェクト: theinze/pyrate
    for r in r2:
        r.draw2d(axarr[3], color=color, plane_normal=pn, up=up)

b = bundles_step3(nrays=36, rpup=7.5, maxfield_deg=5.)
r2 = s.seqtrace(b[0], seq)
for r in r2:
    r.draw2d(ax2, color="blue", plane_normal=pn, up=up)

plt.show()

system_gui_toplevel = UIInterfaceClassWithOptimizableVariables(
    s.elements["stdelem"].surfaces["elem2rear"].shape).query_for_dictionary()

pprint(system_gui_toplevel)


system_dump = Serializer(s)

try:
    os.mkdir(serialization_path)
except FileExistsError:
    pass

system_dump.save_json(serialization_path + "double_gauss.json")
system_dump.save_yaml(serialization_path + "double_gauss.yaml")

# TODO: later
# s2 = Deserializer.load_json(serialization_path + "double_gauss.json",
#                             True, True)
# draw(s2)