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

2952 addition of revised radial build plotting tool #2955

Merged
merged 15 commits into from
Oct 12, 2023

Conversation

chris-ashe
Copy link
Collaborator

@chris-ashe chris-ashe commented Sep 28, 2023

Description

The radial build plotting tool initially created by @ajpearcey has now been revised.

  • You are now able to plot the radial build for scan and non-scan MFILE's.
  • The ability to plot only the inboard build is now an option
  • Integration test for file output created. See test_plot_radial_build.py
  • Preview of output and running instructions added to the documentation
  • The radial build will change in accordance with the tf_in_cs switch
  • plot_proc images have also been added to the documentation to match the presentation of the radial build plotting section

Checklist

I confirm that I have completed the following checks:

  • I have justified any large differences in the regression tests caused by this pull request in the comments.
  • I have added new tests where appropriate for the changes I have made.
  • If I have had to change any existing unit or integration tests, I have justified this change in the pull request comments.
  • If I have made documentation changes, I have checked they render correctly.
  • I have added documentation for my change, if appropriate.

@chris-ashe chris-ashe linked an issue Sep 28, 2023 that may be closed by this pull request
@chris-ashe chris-ashe added the New feature Introduction of a new model / feature label Sep 28, 2023
Copy link
Contributor

@timothy-nunn timothy-nunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see my comments. I think there is scope to simplify and consolidate some of the logic.

"-ib",
"--inboard",
action="store_true",
help="Show inboard build only, default = No ",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default = False as per Python conventions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't noticed this, what you have done is correct... I meant change 'default = No' to 'default = False'

if ifail[ii] == 1:
for jj in range(len(radial_labels)):
radial_build[jj, ll] = m_file.data[radial_labels[jj]].get_scan(ii + 1)
ll += 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be simplified so that there is an array that we append only converged solutions to, and then turn into a numpy array. This was we dont need to count the number of converged solutions and we don't need to do this ugly loop. Let me know if this does not make sense.

# This needs to be kept in sync automatically; this will break frequently
# otherwise
# Rem : Some variables are not in the MFILE, making the defintion rather tricky...
nsweep_dict = dict()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears to be creating a dict where the keys are integers (aka an array), why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No clue

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is copied directly from plot_scan.py and is code originally written by Seb. There is definitely scope to tidy this up. The integer here refers to the scan variable nsweep.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change it to be an array? This will be more idiomatic maybe probably shorter

except Exception:
scan_var_name = "Null"

radial_labels = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a duplicate of the above variable (albeit in a different scope)? If so, could you make it a constant defined at the top (after the imports) of the file.

You could also consider if we could consolidate this information and the LaTex labels together.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in to allow plotting for scanning MFILE's and non scan MFILE's. There is an attempt to get the sweep variable and if its not able to it throws an exception and sets the y-axis to 0

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is I think we define the exact same list twice, and it could just be defined once

`plot_radial_build` is to plot the radial build of the machine in terms of bar segments. It can be run as follows:

```bash
python process/io/plot_radial_build.py -f path/to/MFILE.DAT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should possibly show how the -o flag could be used here too. The others are a bit too obscure to document here.

Copy link
Contributor

@timothy-nunn timothy-nunn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given our in-person discussions, I am happy for this to go in with the view it (and many other utilities) will be improved once we have a rich Python data structure.

@timothy-nunn timothy-nunn merged commit 3e11b37 into main Oct 12, 2023
20 checks passed
@timothy-nunn timothy-nunn deleted the 2952-addition-of-revised-radial-build-plotting-tool branch October 12, 2023 12:33
chris-ashe added a commit that referenced this pull request Apr 22, 2024
* Initial file commit

* bare except flake 8 fix

* Initial no-scan plot attempt

* Integration test and outputdir command option

* remove outputdir

* integration test save directory fix

* Documentation additions

* Added in plot_proc images as extra

* default false argparse

* added -o flag to docs

* default false

* ifail sweep tidy up

* dict to list

* file naming added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
New feature Introduction of a new model / feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Addition of revised radial build plotting tool
3 participants