You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
psyplot projects should be exportable directly to python scripts, not only as
pickle files.
Reason
When trying to reproduce a plot created through the GUI, it would be helpful
to have a python script to generate it, such that it can be copy-pasted to
another python script.
Detailed explanation
One strength of psyplot is the short and easy syntax for formatoptions and
the structured data handling. And since anyway most of the formatoption
come in standard python objects like lists, strings, etc. it would be
straight-forward with python repr function to reproduce them in a script.
Challenges
Only datasets that have been stored to disc can be opened in the
script
The matplotlib axes setup has to be reproduced
Some formatoptions do require more complex data structures, such
as colormaps or numpy arrays
Proposed methodology to generate the script
open the netCDF dataset from disk (if it is stored on the disk, otherwise leaf that
empty such that the user can fill this in
ds1=xr.open_dataset('nc-file1.nc')
ds2=xr.open_dataset('nc-file2.nc')
ds3=# dataset has not been stored on the disc
The number ds<number> should be determined by the psyplot.data.DatasetAccessor.num attribute
We should not use the psyplot.project.plot API directly, since the plot methods
can have diverse calling signatures. So we extract the data and create the plot for
each array in the project from scratch. Therefore, for each data object in the project,
export a script to
reproduce the DataArray (or InteractiveList) from the datasets ds1, ds2, ...
Create the matplotlib axes that is visualized (if there is a plotter)
open the plotter class from psyplot (if there is a plotter)
Concatenate all the extracted data arrays/lists into one project
Proposed API additions:
A new method psyplot.data.ArrayList.to_script() to top-level API method that
generates the python script to reproduce the list/project. It should create the part
to open the datasets and call the to_script method of the contents
A new abstract method psyplot.script.InteractiveBase.to_script() that
generates the string to generate this data structure. If the object has a
plotter, it should call the to_script method of the plotter
A new abstract method psyplot.plotter.Plotter.to_script() method, that
Creates the matplotlib axes
Creates the plotter by first checking the prepare_string methods of the
formatoptions and then the as_string method
A new psyplot.plotter.Formatoption.prepare_string method, that returns
a string with necssary preparations for the formatoption. In case of a
colormap instance, for example, this could be the example how the colormap is
created. So by default, this should be an empty string
A new psyplot.plotter.Formatoption.as_string method, that is called after
the prepare_string method and sets the value for the formatoption in the Plotter(...) initialization. By default, this should just be repr(self.value)
Summary
psyplot projects should be exportable directly to python scripts, not only as
pickle files.
Reason
When trying to reproduce a plot created through the GUI, it would be helpful
to have a python script to generate it, such that it can be copy-pasted to
another python script.
Detailed explanation
One strength of psyplot is the short and easy syntax for formatoptions and
the structured data handling. And since anyway most of the formatoption
come in standard python objects like lists, strings, etc. it would be
straight-forward with python
repr
function to reproduce them in a script.Challenges
script
as colormaps or numpy arrays
Proposed methodology to generate the script
open the netCDF dataset from disk (if it is stored on the disk, otherwise leaf that
empty such that the user can fill this in
The number
ds<number>
should be determined by thepsyplot.data.DatasetAccessor.num
attributeWe should not use the
psyplot.project.plot
API directly, since the plot methodscan have diverse calling signatures. So we extract the data and create the plot for
each array in the project from scratch. Therefore, for each data object in the project,
export a script to
ds1, ds2, ...
Concatenate all the extracted data arrays/lists into one project
Proposed API additions:
A new method
psyplot.data.ArrayList.to_script()
to top-level API method thatgenerates the python script to reproduce the list/project. It should create the part
to open the datasets and call the
to_script
method of the contentsA new abstract method
psyplot.script.InteractiveBase.to_script()
thatgenerates the string to generate this data structure. If the object has a
plotter, it should call the
to_script
method of the plotterA new abstract method
psyplot.plotter.Plotter.to_script()
method, thatprepare_string
methods of theformatoptions and then the
as_string
methodA new
psyplot.plotter.Formatoption.prepare_string
method, that returnsa string with necssary preparations for the formatoption. In case of a
colormap instance, for example, this could be the example how the colormap is
created. So by default, this should be an empty string
A new
psyplot.plotter.Formatoption.as_string
method, that is called afterthe
prepare_string
method and sets the value for the formatoption in thePlotter(...)
initialization. By default, this should just berepr(self.value)
Examples
Paraview for example has this functionality with Tools->Start Trace
The text was updated successfully, but these errors were encountered: