Skip to content

model_generator.py

association_models_generator(assoc_df)

Creates a generator object containing yielded Association objects from an input pipeline association dataframe.

Parameters:

Name Type Description Default
assoc_df pd.DataFrame

The dataframe from the pipeline containing the associations between measurements and sources.

required

Returns:

Type Description
Iterable[Generator[Association, None, None]]

An iterable generator object containing the yielded Association objects.

Source code in vast_pipeline/pipeline/model_generator.py
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
def association_models_generator(
    assoc_df: pd.DataFrame
) -> Iterable[Generator[Association, None, None]]:
    """
    Creates a generator object containing yielded Association objects from
    an input pipeline association dataframe.

    Args:
        assoc_df:
            The dataframe from the pipeline containing the associations between
            measurements and sources.

    Returns:
        An iterable generator object containing the yielded Association objects.
    """
    for i, row in assoc_df.iterrows():
        yield Association(
            meas_id=row['id'],
            source_id=row['source_id'],
            d2d=row['d2d'],
            dr=row['dr'],
        )

measurement_models_generator(meas_df)

Creates a generator object containing yielded Measurement objects from an input pipeline measurement dataframe.

Parameters:

Name Type Description Default
meas_df pd.DataFrame

The dataframe from the pipeline containing the measurements of an image.

required

Returns:

Type Description
Iterable[Generator[Measurement, None, None]]

An iterable generator object containing the yielded Measurement

Iterable[Generator[Measurement, None, None]]

objects.

Source code in vast_pipeline/pipeline/model_generator.py
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
def measurement_models_generator(
    meas_df: pd.DataFrame
) -> Iterable[Generator[Measurement, None, None]]:
    """
    Creates a generator object containing yielded Measurement objects from
    an input pipeline measurement dataframe.

    Args:
        meas_df:
            The dataframe from the pipeline containing the measurements of an
            image.

    Returns:
        An iterable generator object containing the yielded Measurement
        objects.
    """
    for i, row in meas_df.iterrows():
        one_m = Measurement()
        for fld in one_m._meta.get_fields():
            if getattr(fld, 'attname', None) and fld.attname in row.index:
                setattr(one_m, fld.attname, row[fld.attname])
        yield one_m

measurement_pair_models_generator(measurement_pairs_df)

Creates a generator of MeasurementPair objects from an input pipeline measurement pair dataframe.

Parameters:

Name Type Description Default
measurement_pairs_df pd.DataFrame

The DataFrame of measurement pairs.

required

Returns:

Type Description
Iterable[Generator[MeasurementPair, None, None]]

An iterable of MeasurementPair objects, one for each row of

Iterable[Generator[MeasurementPair, None, None]]

measurement_pairs_df.

Source code in vast_pipeline/pipeline/model_generator.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
def measurement_pair_models_generator(
    measurement_pairs_df: pd.DataFrame,
) -> Iterable[Generator[MeasurementPair, None, None]]:
    """
    Creates a generator of MeasurementPair objects from an input pipeline
    measurement pair dataframe.

    Args:
        measurement_pairs_df:
            The DataFrame of measurement pairs.

    Returns:
        An iterable of MeasurementPair objects, one for each row of
        `measurement_pairs_df`.
    """
    for i, row in measurement_pairs_df.iterrows():
        yield MeasurementPair(
            source_id=row["source_id"],
            measurement_a_id=row["id_a"],
            measurement_b_id=row["id_b"],
            vs_peak=row["vs_peak"],
            vs_int=row["vs_int"],
            m_peak=row["m_peak"],
            m_int=row["m_int"],
        )

related_models_generator(related_df)

Creates a generator object containing yielded Association objects from an input pipeline association dataframe.

Parameters:

Name Type Description Default
related_df pd.DataFrame

The dataframe from the pipeline containing the relations between sources.

required

Returns:

Type Description
Iterable[Generator[RelatedSource, None, None]]

An iterable generator object containing the yielded Association objects.

Source code in vast_pipeline/pipeline/model_generator.py
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
def related_models_generator(
    related_df: pd.DataFrame
) -> Iterable[Generator[RelatedSource, None, None]]:
    """
    Creates a generator object containing yielded Association objects from
    an input pipeline association dataframe.

    Args:
        related_df:
            The dataframe from the pipeline containing the relations between
            sources.

    Returns:
        An iterable generator object containing the yielded Association objects.
    """
    for i, row in related_df.iterrows():
        yield RelatedSource(**row.to_dict())

source_models_generator(src_df, pipeline_run)

Creates a generator object containing yielded Source objects from an input pipeline sources dataframe.

Parameters:

Name Type Description Default
src_df pd.DataFrame

The dataframe from the pipeline containing the measurements of an image.

required
pipeline_run Run

The pipeline Run object of which the sources are associated with.

required

Returns:

Type Description
Iterable[Generator[Source, None, None]]

An iterable generator object containing the yielded Source objects.

Source code in vast_pipeline/pipeline/model_generator.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def source_models_generator(
    src_df: pd.DataFrame, pipeline_run: Run
) -> Iterable[Generator[Source, None, None]]:
    """
    Creates a generator object containing yielded Source objects from
    an input pipeline sources dataframe.

    Args:
        src_df:
            The dataframe from the pipeline containing the measurements of
            an image.
        pipeline_run:
            The pipeline Run object of which the sources are associated with.

    Returns:
        An iterable generator object containing the yielded Source objects.
    """
    for i, row in src_df.iterrows():
        name = (
            f"J{deg2hms(row['wavg_ra'], precision=1)}"
            f"{deg2dms(row['wavg_dec'], precision=0)}"
        ).replace(":", "")
        src = Source()
        src.run_id = pipeline_run.id
        src.name = name
        for fld in src._meta.get_fields():
            if getattr(fld, 'attname', None) and fld.attname in row.index:
                setattr(src, fld.attname, row[fld.attname])

        yield src

Last update: March 2, 2022
Created: March 2, 2022