diff --git a/geomagio/processing/magproc.py b/geomagio/processing/magproc.py
new file mode 100644
index 0000000000000000000000000000000000000000..63d9762e2ac96263e537e66e4a57343f170d3d46
--- /dev/null
+++ b/geomagio/processing/magproc.py
@@ -0,0 +1,124 @@
+from os import path
+import os
+import sys
+
+from datetime import datetime
+from dateutil.relativedelta import relativedelta
+from obspy.core import UTCDateTime
+import typer
+
+from ..edge.EdgeFactory import EdgeFactory
+from ..pcdcp import PCDCPFactory, PCDCP_FILE_PATTERN
+from ..residual import WebAbsolutesFactory, CalFileFactory
+
+CAL_FILENAME_FORMAT = "{OBSERVATORY}/{OBSERVATORY}{YEAR}PCD.cal"
+MIN_TEMPLATE = "file://c:/USGSDCP/%(OBS)s/" + PCDCP_FILE_PATTERN
+RAW_TEMPLATE = "%(OBS)s/" + PCDCP_FILE_PATTERN
+
+
+def main():
+    typer.run(prepfiles)
+
+
+def prepfiles(observatory: str, year: int, month: int):
+    starttime = datetime(year, month, 1)
+    endtime = starttime + relativedelta(months=+1)
+
+    write_cal_file(starttime, endtime, observatory)
+
+
+def write_cal_file(
+    starttime, endtime, observatory, base_directory="file://c:/Calibrat/"
+):
+    filename = CAL_FILENAME_FORMAT.format(OBSERVATORY=observatory, YEAR=starttime.year)
+    starttime = starttime + relativedelta(months=-1)
+    endtime = endtime + relativedelta(months=+2)
+    starttime = UTCDateTime(
+        year=starttime.year, month=starttime.month, day=starttime.day
+    )
+    endtime = UTCDateTime(year=endtime.year, month=endtime.month, day=endtime.day)
+    filename = CAL_FILENAME_FORMAT.format(OBSERVATORY=observatory, YEAR=starttime.year)
+    readings = WebAbsolutesFactory().get_readings(
+        observatory=observatory,
+        starttime=starttime,
+        endtime=endtime,
+        include_measurements=True,
+    )
+
+    calfile = CalFileFactory().format_readings(readings=readings)
+
+    with open(base_directory + filename, "wb") as f:
+        f.write(calfile)
+
+
+def write_raw_file(starttime, endtime, observatory, base_directory="file://c:/RAW/"):
+    starttime = UTCDateTime(
+        year=starttime.year, month=starttime.month, day=starttime.day
+    )
+    endtime = UTCDateTime(year=endtime.year, month=endtime.month, day=endtime.day)
+
+    channels = ["H", "E", "Z", "F"]
+
+    edge_factory = EdgeFactory()
+    raw_timeseries = edge_factory.get_timeseries(
+        observatory=observatory,
+        starttime=starttime,
+        endtime=endtime,
+        channels=channels,
+        interval="second",
+        type="variation",
+    )
+
+    raw_factory = PCDCPFactory(
+        observatory=observatory,
+        channels=channels,
+        type="variation",
+        interval="second",
+        urlInterval=86400,
+        urlTemplate=base_directory + f"{RAW_TEMPLATE}",
+    )
+
+    raw_factory.put_timeseries(
+        timeseries=raw_timeseries,
+        starttime=starttime,
+        endtime=endtime,
+        interval="second",
+        type="variation",
+        channels=channels,
+    )
+
+
+def write_min_file(starttime, endtime, observatory, base_directory="file://c:/MIN/"):
+    starttime = UTCDateTime(
+        year=starttime.year, month=starttime.month, day=starttime.day
+    )
+    endtime = UTCDateTime(year=endtime.year, month=endtime.month, day=endtime.day)
+
+    channels = ["H", "E", "Z", "F"]
+
+    min_timeseries = EdgeFactory().get_timeseries(
+        observatory=observatory,
+        starttime=starttime,
+        endtime=endtime,
+        channels=channels,
+        interval="minute",
+        type="variation",
+    )
+
+    min_factory = PCDCPFactory(
+        observatory=observatory,
+        channels=channels,
+        type="variation",
+        interval="minute",
+        urlInterval=86400,
+        urlTemplate=base_directory + f"{MIN_TEMPLATE}",
+    )
+
+    min_factory.put_timeseries(
+        timeseries=min_timeseries,
+        starttime=starttime,
+        endtime=endtime,
+        interval="minute",
+        type="variation",
+        channels=channels,
+    )
diff --git a/setup.py b/setup.py
index 54917b5a0c2af739333057e6eb7dd1ef64f54f4b..b923235ecb0fe6ff2797a6876680058d49160f2a 100644
--- a/setup.py
+++ b/setup.py
@@ -21,4 +21,7 @@ setuptools.setup(
     scripts=["bin/geomag.py", "bin/geomag_webservice.py", "bin/make_cal.py"],
     setup_requires=["setuptools-pipfile",],
     use_pipfile=True,
+    entry_points={
+        "console_scripts": ["magproc-prepfiles=geomagio.processing.magproc:main"],
+    },
 )