chump.objects.mobject2d

class mobject2d(chump.objects.mobject.mobject):

mobject2d represents tabular data structures.

idcol: str

set the column name for site/well ID

a_scale: int | float

apply scaling value a_scale to all values.

a_offset: int | float

apply offset value a_offset to all values.

minlayer: int

Filter data with layers larger than or euqal to minlayer.

maxlayer: int

Filter data with layers smaller than or euqal to maxlayer.

lfunc: str

apply a function over the layers.

Example:

>>> lfunc = 'max'
calculate the maximum values over the layers
mintime: int | float | str | datetime.datetime

Filter data with time larger than or euqal to mintime.

maxtime: int | float | str | datetime.datetime

Filter data with time smaller than or euqal to maxtime.

tfunc: str

apply a function over time.

Example:

>>> tfunc = 'mean'
calculate the mean values over time
transpose: str

if transpose is true, apply transpose.

exttable: dict | list

set external table object(s) to join this object.

Example:

>>> exttable = {csv='wells'}
>>> exttable = [{csv='NEwells'},{csv='KSwells'},{csv='COwells'}]
limits: list

drop values not in limits.

Example:

>>> limits = [1000, 5000]
abslimits: list

drop the absolute values not in abslimits.

Example:

>>> abslimits = [1, 1e10]
countlimit: int

drop the well/site whose value count is smaller than countlimit.

rename: int

rename index or columns.

Example:

>>> rename = {columns={qaq='Simulated'}}
replace: dict

replace value.

Example:

>>> replace = {1e30 = nan}
filter: str

filter the columns of a DataFrame with a boolean expression. see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.query.html.

Example:

>>> filter = 'obsval > 1000'
writedata: bool

set writedata to true to export the data. The data will saved as a CSV or SHP file.

exclude: str

filter a subset of data that will be plotted differernt. also see filter. The plotarg for the data subset is defined by plotarg_exclude.

Examples:

>>> exclude         = 'obsweight == 0'
>>> plotarg_exclude = {color = 'grey', alpha = 0.5}
plotarg_exclude: dict

plot arguments for the excluded data.

drop: dict

drop specified labels from rows or columns, see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.drop.html.

Example:

>>> drop = {columns=['colA','colB']}
fillna: dict

Fill NA/NaN values using the specified method., see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.fillna.html.

Example:

>>> fillna = 0
>>> fillna = {value=0}
resample: dict

resample data to other time frequency. see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.resample.html.

Example:

>>> resample = {rule='7D', func='mean'}
rolling: dict

provide rolling window calculations. see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.rolling.html.

Example:

>>> rolling = {window=12, func='sum'}
subtract: dict

subtract values of another object.

Example:

>>> subtract = {other={csv='obslevel'}, fill_value=0}
add: dict

add values of another object.

Example:

>>> add = {other={csv='obslevel'}, fill_value=0}
mul: dict

multiply values of another object.

Example:

>>> mul = {other={csv='obslevel'}, fill_value=1}
div: dict

divide values of another object.

Example:

>>> div = {other={csv='obslevel'}, fill_value=1}
concat: list | str

concatenate data from other objects with current object.

Examples:

>>> concat = 'head1'
>>> concat = ['head1', 'head2']
calculate: str

set the object as a result of a mathmatic expression. The expression will be evaluated by the Python's eval function.

Examples:

>>> [mfbin.simdiff]
>>> calculate = '(simheadA - simHeadB) - (simheadC - simHeadD)'

where simheadA, simheadB, simheadC and simheadD are names of other mfbin objects.

dfopts: list | dict

perform dataframe operation.

Example:

>>> dfopts = [{diff={}},{sub={other={table='avglevel'}}}]
to_csv: str

write the data to a CSV file.

Example:

>>> to_csv = 'head.csv'
extfunc: str

call a function in an external Python script after reading the data. extfunc sets the file name of the script. This script needs to be placed in the working directory. The function name must be "extfunc" and the first argument is the object. The dataframe of the object can be accessed through obj.dat where obj is the argument name in your function.

Example:

>>> # code inside the external script
>>> def extfunc(obj):
>>>     # extract results for the final 12 month
>>>     obj.dat = obj.dat.iloc[-12:]
writefunc: str

call a function in an external Python script to write data. writefunc sets the file name of the script. This script needs to be placed in the working directory. The function name must be "writefunc" and the first argument is the object. The dataframe of the object can be accessed through obj.dat where obj is the argument name in your function.

Example:

>>> # code inside the external script
>>> import numpy as np
>>> def writefunc(obj):
>>>     # write head results as arrray
>>>     nrow = 50
>>>     ncol = 100
>>>     for (time,layer), r in obj.dat.iterrows():
>>>         np.savetxt(f'time{time}_layer{layer}.dat', r.reshape([nrow, ncol]))
second_y: bool

if second_y is true, the data will be plotted on secondary (on the right) Y axis.

Example:

>>> second_y = true