In [1]:
import pickle

In [4]:
schema = \
    {"Attributes": 
         {"year":    {"dtype": int, 
                      "format": "%4d", 
                      "null": -999,
                      "width": 4},
          "month":   {"dtype": int, 
                      "format": "%02d",
                      "null": -9,
                      "width": 2},
          "day":     {"dtype": int, 
                      "format": "%02d", 
                      "null": -9,
                      "width": 2},
          "hour":    {"dtype": int, 
                      "format": "%02d", 
                      "null": -9,
                      "width": 2},
          "minute":  {"dtype": int, 
                      "format": "%02d", 
                      "null": -9,
                      "width": 2},
          "second":  {"dtype": float, 
                      "format": "%6.3f", 
                      "null": -9.999,
                      "width": 6},
          "cuspid":  {"dtype": int, 
                      "format": "%9d", 
                      "null": -99999999,
                      "width": 9},
          "lat":     {"dtype": float, 
                      "format": "%8.5f", 
                      "null": -9.99999,
                      "width": 8},
          "lon":     {"dtype": float, 
                      "format": "%10.5f",
                      "null": -999.99999,
                      "width": 10},
          "depth":    {"dtype": float,
                      "format": "%7.3f", 
                      "null": -99.999,
                      "width": 7},
          "magnitude":     {"dtype": float, 
                            "format": "%6.3f",
                            "null": -9.999,
                            "width": 6},
          "nph":     {"dtype": int,
                      "format": "%3d", 
                      "null": -99,
                      "width": 3},
          "nearest": {"dtype": int,
                      "format": "%3d",
                      "null": -99,
                      "width": 3},
          "rms":     {"dtype": float, 
                      "format": "%6.2f",
                      "null": -99.99,
                      "width": 6},
          "isnight": {"dtype": int, 
                      "format": "%3d",
                      "null": -99,
                      "width": 3},
          "algorithm": {"dtype": int,
                        "format": "%3d",
                        "null": -99,
                        "width": 3},
          "clustid": {"dtype": int,
                      "format": "%5d",
                      "null": -9999,
                      "width": 5},
          "nclust": {"dtype": int,
                     "format": "%5d",
                     "null": -9999,
                     "width": 5},
          "ndiff": {"dtype": int,
                    "format": "%7d",
                    "null": -999999,
                    "width": 7},
          "aerrh": {"dtype": float,
                    "format": "%7.3f",
                    "null": -99.999,
                    "width": 7},
          "aerrd": {"dtype": float,
                    "format": "%7.3f",
                    "null": -99.999,
                    "width": 7},
          "rerrh": {"dtype": float,
                    "format": "%7.3f",
                    "null": -99.999,
                    "width": 7},
          "rerrd": {"dtype": float,
                    "format": "%7.3f",
                    "null": -99.999,
                    "width": 7},
          "etype": {"dtype": str,
                    "format": "%3s",
                    "null": "-",
                    "width": 3},
          "method": {"dtype": str,
                     "format": "%2s",
                     "null": "-",
                     "width": 2},
          "polygon": {"dtype": str,
                      "format": "%5s",
                      "null": "-",
                      "width": 5},
          "strike": {"dtype": int,
                     "format": "%4d",
                     "null": -999,
                     "width": 4},
          "dip": {"dtype": int,
                  "format": "%3d",
                  "null": -99,
                  "width": 3},
          "rake": {"dtype": int,
                  "format": "%4d",
                  "null": -999,
                  "width": 4},
          "fplane_unc": {"dtype": int,
                         "format": "%3d",
                         "null": -99,
                         "width": 3},
          "aux_fplane_unc": {"dtype": int,
                             "format": "%3d",
                             "null": -99,
                             "width": 3},
          "np_fm": {"dtype": int,
                    "format": "%4d",
                    "null": -999,
                    "width": 4},
          "misfit_fm": {"dtype": float,
                        "format": "%5.2f",
                        "null": -9.99,
                        "width": 5},
          "nsp_ratio": {"dtype": int,
                        "format": "%4d",
                        "null": -999,
                        "width": 4},
          "misfit_avg_ratio": {"dtype": float,
                               "format": "%5.2f",
                               "null": -9.99,
                               "width": 5},
          "qual": {"dtype": str,
                   "format": "%1s",
                   "null": "-",
                   "width": 1},
         },
     "Relations": 
         {"origin":["year", "month", "day", "hour", "minute", "second", "cuspid", "lat",
                     "lon", "depth", "magnitude", "nph", "nearest", "rms", "isnight", "algorithm", 
                     "clustid", "nclust", "ndiff", "aerrh", "aerrd", "rerrh", "rerrd", "etype", 
                     "method", "polygon"],
          "focal": ["year", "month", "day", "hour", "minute", "second", "cuspid", "lat", "lon", 
                    "depth", "magnitude", "strike", "dip", "rake", "fplane_unc", "aux_fplane_unc",
                    "np_fm", "misfit_fm", "nsp_ratio", "misfit_avg_ratio", "qual"]}
    }

In [5]:
with open("../seispy/data/schemas/hys1.0.pkl", "wb") as outf:
    pickle.dump(schema, outf)

In [ ]: