fit_code.rst 1.88 KB
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Fit your code to this project
=============================
Take the main survey (MSC) as an example.
A demo structure is shown below.

.. code-block:: shell

    msc
    ├── __init__.py
    ├── data.py
    │   └── CsstMscImgData class
    └── processor.py
        └── CsstMscImgL0Proc class


The data class
--------------

For each instrument, a specific data class should be constructed.
`CsstData` class is the root class.

.. code-block:: shell

    CsstData
    └── CsstMscData
        └── CsstMscImgData

The pipeline
------------

BO ZHANG's avatar
BO ZHANG committed
31
A pipeline should have the structure like below. (see csst/)
BO ZHANG's avatar
BO ZHANG committed
32

BO ZHANG's avatar
BO ZHANG committed
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
.. code-block:: python

    from csst.core.processor import CsstProcessor

    class CsstProcDemo(CsstProcessor):
        def prepare(self, **args):
            # prepare the environment
            # for example, if you make use of some third-party software like SEXTRACTOR,
            # do your preparation here.
            pass

        def run(self, CsstData, *args, **kwargs):
            # run your pipeline here
            # make sure that your input data should be a child class instance of CsstData.
            pass
BO ZHANG's avatar
BO ZHANG committed
48

BO ZHANG's avatar
BO ZHANG committed
49
50
51
        def cleanup(self, **kwargs):
            # clean up environment
            pass
BO ZHANG's avatar
BO ZHANG committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79


Include your data/config files
------------------------------

added on 2022-04-07

Example: the current astrometry module uses `scamp` to calibrate position.
In your module, use :

.. code-block:: python

    from .. import PACKAGE_PATH
    CONFIG_SCAMP = PACKAGE_PATH + "/msc/config/scamp.default"

In `setup.py`:

.. code-block:: python

    package_data={"": ["LICENSE", "README.md"],
                  "csst": ["msc/config/*",
                           "msc/deepcr_model/*"
                           ]},



Notes
-----
BO ZHANG's avatar
BO ZHANG committed
80
* Use `PEP8 <https://peps.python.org/pep-0008/>`_ style.
BO ZHANG's avatar
BO ZHANG committed
81
82
* DO NOT use `try-except` excessively, particularly in low level code.