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

Feature/kt3 #23

Open
wants to merge 5 commits into
base: development
Choose a base branch
from
Open

Feature/kt3 #23

wants to merge 5 commits into from

Conversation

Mateasek
Copy link
Member

This PR add model of KT3 diagnostic based on FibreOpticGroup. related to issue #18

Based on FibreOpticGroup. Allows user to generate a KT3A or KT3B models
with sightline information or by using the Simple Access Layer to get
sightline information from PPF data.
Shows how a KT3 model can be obtained using SAL.
Shows the sigthlin trajectories in a poloidal plane.
Shows impact of spot position corrections and differences
between KT3A and KT3B sightlines.
Copy link
Member

@vsnever vsnever left a comment

Choose a reason for hiding this comment

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

Thanks, @Mateasek, this PR is superb. I especially liked the feature that allows to adjust the LoS alignment when the view is obstructed by the structure. I have only a few comments and the main one is related to the rarely available PPFs used to read diagnostic parameters.

import numpy as np
from math import sqrt, tan, radians

from jet.data import sal
Copy link
Member

Choose a reason for hiding this comment

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

Replacing this with

from sal.client import SALClient
...
sal = SALClient('https://sal.jet.uk')

will make the code more portable.

We should probably define the DEFAULT_SAL_SERVER. At the moment it is https://sal.jet.uk, but in the near future it will probably change to https://sal.jetdata.eu.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the version of sal from jet package is slightly different isn't it? At least according to what they say here. It seems like this is the SAL version to use for JET. Also, when the default server changes, it should automatically be changed in the jet package, shouldn't it? This way we wouldn't have to care. The same style is used also in the equilibrium loading. Am I missing something?

Copy link
Member

@vsnever vsnever Nov 16, 2021

Choose a reason for hiding this comment

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

You are correct. My point is that with from jet.data import sal this code will run only at JET clusters. With from sal.client import SALClient you can run it from anywhere.

Edit
Of course, we need to replace other usages of jet.data if we want this module to be portable, but that is a separate issue.

Copy link
Member

Choose a reason for hiding this comment

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

Look like sal = SALClient('https://sal.jet.uk') requires authorization on JET Data Center nodes, while from jet.data import sal works without authorization because it's configured for https://sal.jetdata.eu, which is currently unavailable outside of the JDC.
Something like:

try:
    from jet.data import sal
except ModuleNotFoundError:
    # use general SAL client outside of the JET computing infrastructure
    from sal.client import SALClient
    sal = SALClient('https://sal.jet.uk')

will be a better solution.

However, this problem is general for all JET diagnostics implemented in Cherab, and should probably be solved with

from cherab.jet import sal

So, please ignore my comments about this issue, I think it's OK to use from jet.data import sal for now.

Copy link
Member

Choose a reason for hiding this comment

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

@Mateasek pointed out that the JET version of the SAL client can be installed on local machines by following the instructions from https://data.jet.uk/guides/sal/downloads.html#sal-downloads-label. Thus, replacing jet.data.sal with a generic sal does not make cherab.jet more portable as I mistakenly thought.

# empirically determined point limiting the inner sightlines
KT3_INNER_THRESHOLD = Point2D(3.0510967354232994, 2.0072688526617264)

def kt3_from_data(spectrometer, origin_rz, spots_rz, min_wavelength, max_wavelength, spectral_bins, pixel_samples=1e3,
Copy link
Member

Choose a reason for hiding this comment

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

I would rename it to load_kt3_from_data() to match the naming of other load_some_diagnostic() functions in cherab.jet.

Comment on lines +112 to +121
if spectrometer.lower() in ("a", "kt3a"):
leaf_origin = "/pulse/{0:d}/ppf/signal/jetppf/t3af/rzor".format(int(pulse_number))
leaf_spot_tile5 = "/pulse/{0:d}/ppf/signal/jetppf/t3af/rzdv".format(int(pulse_number))
leaf_wave = "/pulse/{0:d}/ppf/signal/jetppf/t3af/wave".format(int(pulse_number))
spectrometer = "KT3A"
elif spectrometer.lower() in ("b", "kt3b"):
leaf_origin = "/pulse/{0:d}/ppf/signal/jetppf/t3bf/rzor".format(int(pulse_number))
leaf_spot_tile5 = "/pulse/{0:d}/ppf/signal/jetppf/t3bf/rzdv".format(int(pulse_number))
leaf_wave = "/pulse/{0:d}/ppf/signal/jetppf/t3bf/wave".format(int(pulse_number))
spectrometer = "KT3B"
Copy link
Member

Choose a reason for hiding this comment

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

Unfortunately, these PPFs are produced on-demand. Among the 19500 pulses between 80124 and 99624, the T3AF and T3BF PPFs are available only in 33 and 290 pulses, respectively. Therefore, it would be nice to have some fallback values for origin_rz, spots_rz and wave.

Looks like the origin_rz (the first mirror position) is fixed at (3.28422, 3.56166) for all the ILW pulses. So, the problem is to obtain spots_rz and wave. I think that the wave can be obtained from the settings specified in the JPF using the equation for the dispersion of the Czerny-Turner spectrometer.

I see three possible solutions for spots_rz:

  1. Calling kt3a(b)_los_siw_new() from home/cxs/instrument_data/kt3_common/alignment through idlbridge.
  2. Implementing the parts of the kt3a(b)_los_siw_new(), agm_image_to_divertor() and agm_divertor_mark2() in python.
  3. Hardcoding the {pulse1: spots_rz1, pulse2: spots_rz2, ...} dictionaries, in which the spots_rz1 is valid between the pulses pulse1 and pulse2.

The first solution is not portable. The second one requires some efforts and can only be implemented with the permission of Andy Meigs. My guess is that the rz_spots rarely changes, so the third solution might work. I'll check it out.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for pointing this out @vsnever . I didn't notice because the shot ensemble I'm working with. I will contact Andy Meigs to discus with him what could be the best way forward, but for myself:

  1. Would cause a lot of problems to a lot of people and as you said it would not work remotely. I think this is not an option.
  2. This would be the best solution in my opinion. Or getting the data from other files, we will see.
  3. Having a default data would be a last resort solution.

I will inform here when I get some information.

Copy link
Member

Choose a reason for hiding this comment

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

I'm currently working on the 3rd solution by obtaining the values of spots_rz using kt3a(b)_los_siw_new() for the entire set of ILW pulses. So far I have found that spots_rz depends on the grating, which varies from pulse to pulse, but can only take on 3 values: 300, 1200 and 2400, while for the same grating, the spots_rz changes very rarely.

Copy link
Member Author

Choose a reason for hiding this comment

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

Lets wait for Andy Meigs before we jump to reverse engineering.


return group

def kt3_from_sal(spectrometer, pulse_number,min_wavelength=None, max_wavelength=None, spectral_bins=None,
Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is a default way of loading the diagnostic, so the name load_kt3() would do better I think.

return group

def kt3_from_sal(spectrometer, pulse_number,min_wavelength=None, max_wavelength=None, spectral_bins=None,
spot_position_correction=True, pulse_time=None, time_selection="nearest",
Copy link
Member

Choose a reason for hiding this comment

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

I would change the default value for spot_position_correction to False. The private PPF required for the spot correction may not be available.

Changed names to match package convention,
changed default value of spot_position_correction to False
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