def plot(self, gname=None, sname=None, mtype=None, series=None, stype=None, sval=None, sval_range=None, mean=False, groupmean=False, invert=False, id=None, **plt_props): samples = self.get_sample( sname=sname, mtype=mtype, series=series, stype=stype, sval=sval, sval_range=sval_range, mean=mean, invert=invert, ) mlists = [[ m for m in s.get_measurement(mtype=mtype, series=series, stype=stype, sval=sval, sval_range=sval_range, mean=mean, invert=invert, id=id) if m._visuals ] for s in samples] columns = max(len(ml) for ml in mlists) if any(m for m in mlists): fig = RockPy3.Figure(title=self.name, columns=columns) for ml in mlists: for m in ml: vidx = deepcopy(fig._n_visuals) m.add_visuals(fig, **plt_props) v = fig.visuals[vidx][2] v.title = ' '.join((m.sobj.name, v.title)) if m.has_series(): stuples = '\n'.join('{}'.format(s) for s in m.series) with RockPy3.ignored(IndexError): fig.visuals[vidx][2].add_feature('generic_text', transform='ax', s=stuples, x=0.05, y=0.9) fig.show()
def plot(self, mtype=None, series=None, stype=None, sval=None, sval_range=None, mean=False, invert=False, id=None, result=None, **plt_props): mlist = self.get_measurement(mtype=mtype, series=series, stype=stype, sval=sval, sval_range=sval_range, mean=mean, invert=invert, id=id, result=result) # max_columns = max(len(m._visuals) for m in mlist) max_columns = sum(len(m._visuals) for m in mlist) if len(mlist) < 4 else max( len(m._visuals) for m in mlist) fig = RockPy3.Figure(title=self.name, columns=max_columns) for m in mlist: # get index of the first visual of this measurement vidx = deepcopy(fig._n_visuals) # only add the measurement if it has _visuals defined (e.g. no mass measurements) if m._visuals: m.add_visuals(fig, **plt_props) if m.has_series(): stuples = '\n'.join('{}'.format(s) for s in m.series) with RockPy3.ignored(IndexError): fig.visuals[vidx][2].add_feature('generic_text', transform='ax', s=stuples, x=0.05, y=0.9) fig.show()
def test__add_input_to_plot(self): # only samples without mean NoMeanStudy = RockPy3.RockPyStudy(name='NoMeanStudy') # only samples with mean MeanStudy = RockPy3.RockPyStudy(name='MeanStudy') # samples with mean and without MixedStudy = RockPy3.RockPyStudy(name='MixedStudy') # # sample without mean NoMeanSample = RockPy3.Sample() Measurement_NoMeanSample = NoMeanSample.add_simulation(mtype='hys') # # sample with mean MeanSample = RockPy3.Sample() Measurement_MeanSample1 = MeanSample.add_simulation(mtype='hys') Measurement_MeanSample2 = MeanSample.add_simulation(mtype='hys') MeanMeasurement12 = MeanSample.create_mean_measurement(mtype='hys') # NoMeanStudy.add_sample(sobj=NoMeanSample) MeanStudy.add_sample(sobj=MeanSample) MixedStudy.add_sample(sobj=NoMeanSample) MixedStudy.add_sample(sobj=MeanSample) SampleList = [NoMeanSample, MeanSample] NoMeanList = [Measurement_NoMeanSample, Measurement_MeanSample1] MeanList = [Measurement_NoMeanSample, Measurement_MeanSample1, MeanMeasurement12] for i, test in enumerate([NoMeanStudy, MeanStudy, MixedStudy, #NoMeanSample, MeanSample, # Measurement_NoMeanSample, Measurement_MeanSample1, # SampleList, NoMeanList, MeanList ]): fig = RockPy3.Figure() v = fig.add_visual('hysteresis') # print('plot_mean=True, plot_base=True') mlist = v._add_input_to_plot(test, plot_mean=True, plot_base=True, base_alpha=0.1) # print('plot_mean=False, plot_base=True') mlist_NoMean = v._add_input_to_plot(test, plot_mean=False, plot_base=True, base_alpha=0.2) # print('plot_mean=True, plot_base=False') mlist_NoBase = v._add_input_to_plot(test, plot_mean=True, plot_base=False, base_alpha=0.3) # print('plot_mean=False, plot_base=False') mlist_NoMeanNoBase = v._add_input_to_plot(test, plot_mean=False, plot_base=False, base_alpha=0.4) # print('plot_mean=False, plot_base=False, plot_other=False') mlist_Nothing = v._add_input_to_plot(test, plot_mean=False, plot_base=False, plot_other=False) if i == 0: #NoMeanStudy self.assertEquals([Measurement_NoMeanSample], mlist) self.assertEquals([Measurement_NoMeanSample], mlist_NoMean) self.assertEquals([Measurement_NoMeanSample], mlist_NoBase) self.assertEquals([Measurement_NoMeanSample], mlist_NoMeanNoBase) self.assertEquals([], mlist_Nothing) # alpha_prop = [m._plt_props['alpha'] for m in mlist_NoMean] # self.assertFalse(all(i == 0.1 for i in alpha_prop)) if i == 1: #MeanStudy self.assertEquals([MeanMeasurement12, Measurement_MeanSample1, Measurement_MeanSample2], mlist) self.assertEquals([Measurement_MeanSample1, Measurement_MeanSample2], mlist_NoMean) self.assertEquals([MeanMeasurement12], mlist_NoBase) self.assertEquals([], mlist_NoMeanNoBase) alpha_prop = [m._plt_props['alpha'] for m in mlist_NoMean if 'alpha' in m._plt_props] self.assertEqual([0.1, 0.1], alpha_prop) if i == 2: #MixedStudy self.assertEquals([MeanMeasurement12, Measurement_MeanSample1, Measurement_MeanSample2, Measurement_NoMeanSample], mlist) self.assertEquals([Measurement_MeanSample1, Measurement_MeanSample2, Measurement_NoMeanSample], mlist_NoMean) self.assertEquals([MeanMeasurement12, Measurement_NoMeanSample], mlist_NoBase) self.assertEquals([Measurement_NoMeanSample], mlist_NoMeanNoBase) alpha_prop = [m._plt_props['alpha'] for m in mlist_NoMean if 'alpha' in m._plt_props] self.assertEqual([0.1, 0.1], alpha_prop)
def set_colorscheme(scheme): RockPy3.colorscheme = RockPy3.core.utils.colorscheme(scheme) return RockPy3.core.utils.colorscheme(scheme) if __name__ == '__main__': # pass # S = RockPy3.Study # s = S.add_sample(name='S1') # s.add_simulation(mtype='hysteresis') # # fig = RockPy3.Figure() # v = fig.add_visual(visual='hysteresis', data=S) # print(v.data) # for f in v.features: # print(v.features[f]['data']) # # fig.show() # print(RockPy3.implemented_measurements.keys()) # print(RockPy3.implemented_visuals.keys()) RockPy3.set_fontsize(fontsize=14) RockPy3.core.utils.setLatex(True) fig = RockPy3.Figure() v = fig.add_visual('hysteresis') v.enumerate() fig.show()
import inspect class Thermocurve(Visual): def init_visual(self): self.standard_features = ['zero_lines', 'thermocurve_data'] self.xlabel = 'Temperatures' self.ylabel = 'Moment $Am^2$' @plot(mtypes=['thermocurve'], overwrite_mobj_plt_props={'marker':''}) def feature_thermocurve_data(self, mobj, plt_props=None): RockPy3.Packages.Mag.Features.thermocurve.thermocurve_data(self.ax, mobj, **plt_props)\ @plot(mtypes=['thermocurve'], overwrite_mobj_plt_props={'marker':''}) def feature_thermocurve_data_colored(self, mobj, plt_props=None): RockPy3.Packages.Mag.Features.thermocurve.thermocurve_data_colored(self.ax, mobj, **plt_props) @plot(mtypes=['thermocurve'], overwrite_mobj_plt_props={'marker': ''}) def feature_thermocurve_derivative(self, mobj, twinx=True, plt_props=None): RockPy3.Packages.Mag.Features.thermocurve.thermocurve_derivative(self.ax, mobj, **plt_props) if __name__ == '__main__': vftb_rmp = '/Users/Mike/Dropbox/experimental_data/pyrrhotite/VFTB/msm17591final.rmp' s2 = RockPy3.Study.add_sample(name='MSM17591') m = s2.add_measurement(mtype='rmp', ftype='vftb', fpath=vftb_rmp) f = RockPy3.Figure(data=s2, figsize=(6, 3)) v = f.add_visual('thermocurve') v.add_feature('thermocurve_derivative', twinx=True) v.title = s2.name f.show(xlim=(20, 350))
def QuickFig(data, visuals, **kwargs): f = RockPy3.Figure(data=data) visuals = RockPy3._to_tuple(visuals) for v in visuals: f.add_visual(visual=v) f.show(**kwargs)
plt_props['alpha'] = 0.7 RockPy3.Packages.Mag.Features.day.sd_sp_10nm(ax=self.ax, **plt_props) @plot(single=True) def feature_errorbars(self, plt_props=None): # after Dunlup2002a plt_props['color'] = 'k' plt_props['alpha'] = 0.7 RockPy3.Packages.Mag.Features.day.errorbars(ax=self.ax, mobj=plt_props.pop('mobj'), **plt_props) if __name__ == '__main__': Study = RockPy3.Study s = Study.add_sample(name='S1') hys = s.add_measurement( mtype='hysteresis', fpath='/Users/Mike/GitHub/RockPy_presentation/hys.001', ftype='vsm') coe = s.add_measurement( mtype='backfield', fpath='/Users/Mike/GitHub/RockPy_presentation/coe.001', ftype='vsm') fig = RockPy3.Figure(data=Study) v = fig.add_visual(visual='day', color='r', markersize=10, xlims=[1, 6]) # print(v.xlims) v.add_feature(feature='sd_md_mixline_1', marker='') fig.show()
# # dictionaries # self._mdict = self._create_mdict() # self._mean_mdict = self._create_mdict() # self._rdict = self._create_mdict() self.index = MeanSample.snum self._samplegroups = [] self.study = RockPy3.Study self.idx = MeanSample.snum MeanSample.snum += 1 def __repr__(self): return '<< RockPy.MeanSample.{} >>'.format(self.name) if __name__ == '__main__': RockPy3.logger.setLevel('DEBUG') #S = RockPy3.RockPyStudy(folder='/Users/mike/Dropbox/experimental_data/pyrrhotite/hys||c') S = RockPy3.RockPyStudy( folder= '/Users/mike/Dropbox/experimental_data/FeNiX/FeNi20K/separation test') f = RockPy3.Figure(data=S) v = f.add_visual('hysteresis') v = f.add_visual('hysteresis', features='reversible_data') v = f.add_visual('hysteresis', features='irreversible_data') f.show()