Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add colormap option for plot_grid_var.py and grid_var frame generation #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

samueltootle
Copy link

A small addition to plot_grid_var.py and grid_var to allow changing the colormap of 2D slices via CLI.

@Sbozzolo
Copy link
Owner

Sbozzolo commented Jul 4, 2022

Thanks!

I think we can do a little bit better: we can make all the parameters adjustable.

Here's a couple of ways to do so:

  1. Do something like this to set the parameters via command-line. The problem that I see is that by default everything is treated as a string, which might not work.
  2. Add a command-line option to specify a config file (possibly controllable via env variable) to set up matplotlib parameters.

The file argparse_heper.py will allow us to make either changes in a relatively clean way for all the files. I think 2 is simpler, but 1 is more flexible because you don't need to create a file to change the parameters. Do you have thoughts about this?

@samueltootle
Copy link
Author

Regarding option 1, the string treatment isn't a big deal per say - it's python after all.

Overall option 2 is more appealing. The reason for this is simple: I'm already creating shell files with command lines that i use often or repeatedly. Long commands become increasingly unreadable and not maintainable.

A config file would be a nice alternative so long as it could be done in such a way as to reduce significant refactoring. A compromise would also need to be made in the case that config files allow for more options than the standard CLI interface such that a separate help would need to be available to list the available options without requiring the user to go to the website. That's just my 2¢ at least.

With that said, the current setup with the inclusion of cmap covers 75% of my use cases with the 25% being plots that require custom plots altogether. So, from my side, the level of effort required for either implementation is not really worth the gain from my limited perspective.

If i were to put my effort somewhere it would be Jhuki. Hopefully I have some time after writing my thesis as I have a plan in mind that would automate par file generation for FUKA ID since the python bindings already exist.

@Sbozzolo
Copy link
Owner

Sbozzolo commented Jul 5, 2022

FYI, you can write config files instead of shell scripts (see, --help). You can also intermix setting options from the command line and from config files.

I implemented 2. in next. Now, you can provide a matplotlib configuration file to command-line scripts. In your case, you can create a file named, e.g., ~/.mympl.rc. Then, you can either set up the env variable KBIT_MPL_RC_FILE=~/.mympl.rc (or pass the command-line flag --mpl-rc-file ~/.mympl.rc and add your personal configurations in that file. For example, if you just want to change the colormap, the file will be

image.cmap: viridis

Is this a good solution to your use case?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants