Skip to content

Up for discussion: Cut_throughs with curves, spectrum calculations, static streamlines vol centering#147

Merged
markusbattarbee merged 38 commits intofmihpc:masterfrom
alhom:cut_through_spectra
May 23, 2022
Merged

Up for discussion: Cut_throughs with curves, spectrum calculations, static streamlines vol centering#147
markusbattarbee merged 38 commits intofmihpc:masterfrom
alhom:cut_through_spectra

Conversation

@alhom
Copy link
Copy Markdown
Member

@alhom alhom commented May 17, 2021

Cut_through for arbitrary curves, which precipitated some fixes to cut_through indexing etc.,
and proper volume-centering options for static_streamline. Lifted vdf energy spectrum calculations from old scripts to pyCalculations for ease of use, need to at least finalize comments/help texts.

alhom added 18 commits July 15, 2020 14:14
… vector outputs (I dont remember anymore why I did that.)
…ent usage and began work on curve support for cut-through
…ill, tested against a regular cut-through, seems to work. Tightened the epsilon in regular cut-through.
…rt for static_field_tracer, with a) automatic detection of vol in variable name and b) a keyword parameter to force centering. Added a spherical inner boundary trace stop parameter to static_field_tracer.
…ra v-cell coordinate sampling, commented out some debug lines. Added possibility of selecting spectra weights.
…e.g. flux function values at null points to be plotted with flux function contours
@markusbattarbee
Copy link
Copy Markdown
Contributor

so def get_scaled_var() replicates what was somewhat available already in

def scaleunits(datamap_info, vscale):

Could you then also rework the current plotting tools to use the new method so we don't have overlapping approaches and fragmentation of code?

@alhom
Copy link
Copy Markdown
Member Author

alhom commented Sep 28, 2021

So, the get_scaled_var is a bit suboptimal approach as it copies the whole array. Should we implement slicing operators for variable_info, so that for some variable_info var: var[index] would return var.data[index]*vscale?

…mpling 3) variableinfo specialist units reworking
…aleunits behaviour, and pointed occurrences of that to the new scaler using the new metadata getter.
@alhom
Copy link
Copy Markdown
Member Author

alhom commented Nov 26, 2021

So the above get_scaled_var issue was worked around by letting the user get just the scaling factors.

…izes, fixed variable scaler unknown keyword exception
@alhom
Copy link
Copy Markdown
Member Author

alhom commented Mar 29, 2022

So this PR is getting a bit crowded, since I have built whatever I have used in eVlasiator survey on this branch - up for merge?

Copy link
Copy Markdown
Contributor

@markusbattarbee markusbattarbee left a comment

Choose a reason for hiding this comment

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

Not a lot of changes but e.g. some suggestions about default behaviour

Comment thread pyPlots/plot_colormap.py Outdated
Comment thread pyPlots/plot_colormap.py Outdated
Comment thread pyPlots/plot_colormap.py Outdated
Comment thread pyCalculations/variable.py Outdated
Comment thread pyCalculations/variable.py
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py
print("Error in rotation: testvector ",count,testvect," not a unit vector")
if abs(1.0-np.amax(testvect))>1.e-3:
print("Error in rotation: testvector ",count,testvect," largest component is not unity")
else:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So what does this resampler actually do that is different from the old version?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It handles the re-meshing the original v-mesh to a cubic grid aligned with the output bins, so there is no alias effect from the histogramming. I have to say though, that that is not implemented for each case, or slicethickness. Blimey, that needs still some work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, looking forward to seeing that in action in a complete form!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm. If the resampleReducer does not need the VX, VY, Voutofslice values etc, shouldn't it be called under a separate if at around line 330? And then it can return before doing all these vector calculations and rotations.

Also, because the resampleReducer doesn't support flux weighting (not that anyone has used it here at all), there should probably be a check to see if that combo was requested? or if flux weighting is requested, re-route to the old histogramming.

@alhom
Copy link
Copy Markdown
Member Author

alhom commented Apr 11, 2022

A bunch of updates, incl. more controls for vdf plotting, and better (yet incomplete) support for the vdf resampler.

@alhom
Copy link
Copy Markdown
Member Author

alhom commented Apr 14, 2022

So the resampler is now a bit more finished, but I noticed also I haven't made the switch of defaults yet.

Copy link
Copy Markdown
Contributor

@markusbattarbee markusbattarbee left a comment

Choose a reason for hiding this comment

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

A bit of head-scratching about flux weighting, among other stuff.

For plot_vdf we could even consider dropping flux weighting as an option altogether as it doesn't really make much sense, but on the other hand might as well have it tag along. But I think (?) that there are issues with the integrations inside spectra.py

Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyCalculations/spectra.py Outdated
Ekin[Ekin > max(EkinBinEdges)] = max(EkinBinEdges)
# normalization
if(weight == 'flux'):
fw = f*np.sqrt(V2) # use particle flux as weighting
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For differential flux density, we should have:

fw = f * (dV**3) * np.sqrt(V2) / (Ekin * 4*np.pi) for particles per steradian per eV per square metre per second;
units = "1/(s m^2 sr eV)"
latexunits = '$\mathrm{s}^{-1}\,\mathrm{m}^{-2}\,\mathrm{sr}^{-1}\,\mathrm{eV}^{-1}$'
latex='$\mathcal{F}(\vec{r})$'

Comment thread pyCalculations/spectra.py Outdated
latexunits = '$\mathrm{s}\,\mathrm{m}^{-2}\,(4\pi\,\mathrm{eV})^{-1}$'
latex='$f(\vec{r})v\,\DeltaE\,sr^-1$'
else:
fw = f
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and for number density we should have
fw = f * (dV**3) / Ekin
units = "1/(m^3 eV)"
latexunits = '$\mathrm{m}^{-3}\,\mathrm{eV}^{-1}$'
latex='$f(\vec{r})$'

Comment thread pyCalculations/spectra.py Outdated
weight = 'particles'
dV = np.prod(vlsvReader.get_velocity_mesh_dv(population))
# compute histogram
(nhist,edges) = np.histogram(Ekin,bins=EkinBinEdges,weights=fw*dV,normed=0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And then we should get rid of the dV here and on lines 85, 88, methinks. Thoughts?

Similar corrections needed to the other two routines as well.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So the dV(**3) goes in on line 83 (and ftotal wasn't even used from 85, got rid of that), so that was accounted there. But yes, maybe better move that to a more explicit position.
... but blergh. The energy bin width is accounted for, but yeah, that Ekin is missing all the way from the old create_time_energy_spectrogram.py. It does make sense in that that then integration over the E bins (taking the edge values) gives the total, again. With log bins, \Delta E even goes \propto E, so it's... almost the same, cough.

alhom added 2 commits May 13, 2022 16:00
…flux weighting for alongaxis-velocity; feel free to reimplement if those are needed, _in the specific manner required_.
Copy link
Copy Markdown
Contributor

@markusbattarbee markusbattarbee left a comment

Choose a reason for hiding this comment

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

a few errors

Comment thread pyCalculations/spectra.py
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
Comment thread pyPlots/plot_vdf.py Outdated
alhom added 2 commits May 23, 2022 14:17
…ersion to eV in spectra.py instead of a mess-able q kword, removed unused frame kword (anyway better for the user to do whatever conversions explicitly?)
@markusbattarbee markusbattarbee merged commit d6407a8 into fmihpc:master May 23, 2022
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