Skip to content

neptoon.corrections.factory

build_corrections

Classes:

Functions:

CorrectionBuilder

CorrectionBuilder()

Staging place for the corrections as they are built. First a user adds a check using the add_check method.

Parameters:

Name Type Description Default
corrections dict

dictionary which contains the corrections. The key is the correction_type assigned in each correction, the value is the correction itself.

required

add_correction

add_correction(correction)

Adds a correction to the CorrectionBuilder

Parameters:

Name Type Description Default
correction Correction

A Correction object

required

remove_correction_by_type

remove_correction_by_type(correction_type)

Removes a correction from the CorrectionBuilder based on its type

Parameters:

Name Type Description Default
correction_type str

The type of correction to be removed

required

get_corrections

get_corrections()

Returns the corrections stored in the builder

CorrectNeutrons

CorrectNeutrons(crns_data_frame, correction_builder)

CorrectNeutrons class handles correcting neutrons for additional influences beyond soil moisture. It takes in a crns_data_frame which is a pd.DataFrame which stores the required data.

Methods are available for staging a series of corrections which are applied to remove additional influences on the neutron signal. A user can add corrections individually, or create a CorrectionBuilder class seperately that has been pre-compiled and inject that into the CorrectNeutrons instance.

Once the CorrectionBuilder has been appropriately staged with desired corrections, the correct_neutrons method will apply each correction, record the correction factor and create a corrected epithermal neutron count column with the correction factors applied.

Attributes for using the CorrectNeutrons class

Parameters:

Name Type Description Default
crns_data_frame DataFrame

A DataFrame which contains the appropriate information to apply corrections.

required
correction_builder CorrectionBuilder

Staging area for corrections. Can be built or supplied completed.

required

add_correction

add_correction(new_correction)

Add an invidual correction to the CorrectionBuilder

Parameters:

Name Type Description Default
new_correction Correction

The new correction to apply

required

add_correction_builder

add_correction_builder(new_correction_builder)

Add a whole correction builder. Useful if a correction builder has been built somewhere in the code and you want to read it in.

Parameters:

Name Type Description Default
new_correction_builder CorrectionBuilder

A pre-compiled correction builder.

required

create_correction_factors

create_correction_factors(df)

Cycles through all the corrections in the CorrectionBuilder and applies them to the DataFrame. Returns the DataFrame with additional columns.

Parameters:

Name Type Description Default
df DataFrame

DataFrame which is prepared for correction.

required

Returns:

Type Description
DataFrame

DataFrame with additional columns applied during correction.

create_corrected_neutron_column

create_corrected_neutron_column(df)

Calculates the corrected neutron count rate after applying all the corrections.

NOTE:

Parameters:

Name Type Description Default
df DataFrame

DataFrame with the corrections applied and recorded in the columns

required

Returns:

Type Description
DataFrame

DataFrame with the corrected epithermal neutron count recorded in a column

create_corrected_neutron_uncertainty_column

create_corrected_neutron_uncertainty_column(df)

Creates corrected epithermal neutron uncertainty data

Parameters:

Name Type Description Default
df DataFrame

DataFrame

required

correct_neutrons

correct_neutrons()

Corrects neutrons using the CorrectionBuilder. Returns the DataFrame.

Returns:

Name Type Description
df DataFrame

DataFrame returned with additional columns.

CorrectionFactory

CorrectionFactory()

Used inside the CRNSDataHub when selecting which corrections to apply. Creating a correction involves providing a CorrectionType and (optionally) a CorrectionTheory. The factory will then use information from the SiteInformation object to create a Correction with the appropriate information provided. Additionally a user can register a custom correction for use in processing.

create_correction

create_correction(correction_type, correction_theory=None)

Creates a particular Correction. CorrectionType and CorrectionTheory enums are used for selection. If CorrectionTheory is left empty the default correction is selected.

Parameters:

Name Type Description Default
correction_type CorrectionType

The correction type to stage can be: - CorrectionType.INCOMING_INTENSITY - CorrectionType.ABOVE_GROUND_BIOMASS - CorrectionType.PRESSURE - CorrectionType.HUMIDITY - CorrectionType.CUSTOM

required
correction_theory CorrectionTheory

The theory to apply leave blank to use the default format, otherwise see CorrectionTheory for options, by default None

None

Returns:

Type Description
Correction

Returns a correction object with the site specific values read in from the SiteInfo class

create_intensity_correction

create_intensity_correction(correction_theory)

Internal method for selecting the incoming neutron intensity correction to use. If no CorrectionTheory supplied it will use the default.

Parameters:

Name Type Description Default
correction_theory CorrectionTheory

The CorrectionTheory to use

required

Returns:

Type Description
Correction

Intensity correction with values filled in.

create_biomass_correction

create_biomass_correction(correction_theory)

Internal method for selecting the above ground biomass correction to use. If no CorrectionTheory supplied it will use the default.

NOTE:

Parameters:

Name Type Description Default
correction_theory CorrectionTheory

The CorrectionTheory to use

required

Returns:

Type Description
Correction

Above Ground Biomass correction with values filled in.

create_pressure_correction

create_pressure_correction(correction_theory)

Internal method for selecting the correct pressure correction to use.

Parameters:

Name Type Description Default
correction_theory CorrectionTheory

The CorrectionTheory to apply

required

Returns:

Type Description
Correction

Returns a pressure Correction with values inserted.

create_humidity_correction

create_humidity_correction(correction_theory=None)

Internal method for selecting the correct humidity correction to use

Parameters:

Name Type Description Default
correction_theory CorrectionTheory

The CorrectionTheory to apply

None

Returns:

Type Description
Correction

Returns the Correction

register_custom_correction

register_custom_correction(correction_type, theory, correction_class)

Used to register a custom correction theory. Without registration the correction cannot be used.

The correction_class must be an object which inherits the Correction class and follows the same principles as other Correction type objects. This means it requires an apply method, which takes in a dataframe and returns a dataframe along with updates calulcated along the way.

The key difference of a custom Correction class is that it must take a SiteInformation object. The logic under apply() will then use this SiteInformation object to collect relevant information for processing.

Parameters:

Name Type Description Default
correction_type CorrectionType

The type of correction being registered

required
theory str

A name for the custom correction

required
correction_class Correction

A custom Correction class. See documentation on how to make this.

required

Raises:

Type Description
ValueError

If the correction class is not a Correction type object it throws an error