chump.objects.mobject2d
mobject2d
represents tabular data structures.
apply a function over the layers.
Example:
>>> lfunc = 'max'
calculate the maximum values over the layers
Filter data with time larger than or euqal to mintime
.
Filter data with time smaller than or euqal to maxtime
.
apply a function over time.
Example:
>>> tfunc = 'mean'
calculate the mean values over time
set external table object(s) to join this object.
Example:
>>> exttable = {csv='wells'}
>>> exttable = [{csv='NEwells'},{csv='KSwells'},{csv='COwells'}]
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'
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}
drop specified labels from rows or columns, see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.drop.html.
Example:
>>> drop = {columns=['colA','colB']}
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 data to other time frequency. see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.resample.html.
Example:
>>> resample = {rule='7D', func='mean'}
provide rolling window calculations. see https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.rolling.html.
Example:
>>> rolling = {window=12, func='sum'}
subtract values of another object.
Example:
>>> subtract = {other={csv='obslevel'}, fill_value=0}
multiply values of another object.
Example:
>>> mul = {other={csv='obslevel'}, fill_value=1}
divide values of another object.
Example:
>>> div = {other={csv='obslevel'}, fill_value=1}
concatenate data from other objects with current object.
Examples:
>>> concat = 'head1'
>>> concat = ['head1', 'head2']
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.
perform dataframe operation.
Example:
>>> dfopts = [{diff={}},{sub={other={table='avglevel'}}}]
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:]
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]))
if second_y
is true, the data will be plotted on secondary (on the right) Y axis.
Example:
>>> second_y = true