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

Non ideal optics to emulate manufacturing errors? #223

Open
NuggetOfficial opened this issue Feb 8, 2024 · 0 comments
Open

Non ideal optics to emulate manufacturing errors? #223

NuggetOfficial opened this issue Feb 8, 2024 · 0 comments

Comments

@NuggetOfficial
Copy link

Dear team,

Im running into a bit of a low end error when trying to do some slightly hacky stuff with the VectorVortexCoronagraph.

For my M.Sc. thesis I am simulating optics such as the VectorVortexCoronagraph and the effect of manufacturing errors on the performance of these optics. In essence, Im implementing the footprint of (in my case) a direct writing system in the vortex patterns that I simulate.

This footprint is a mapping function that says: if I try to write this fast axis orientation (fao), the actual fao that I get will be that instead. When you use something along the lines of a closure in python, this means that I make a function f: x |-> x' where x'-x is the systematic fao offset given x.

Or in pythonic expression

def manufacturing_mapping_closure(x:Field, *arguments_needed_to_close_function) -> Field:
    y: Field = do_something(x)
    return y

# create completely closed f: x |-> x'
manufacturing_mapping_function = partial(manufacturing_mapping_factory, *arguments_needed_to_close_function)

I then take the VectorVortexCoronagraph code and in the __init__ I add a parameter called something like manufacturing_map
and in the make_instance method I wrap the fast_axis_orientation parameter this map:

class NonIdealVectorVortexCoronagraph(hp.AgnosticOpticalElement):
    (...)

    def __init__(self, charge, manufacturing_mapping_function:Callable, lyot_stop=None, ...):
        (...)
        self.manufacturing_map= manufacturing_mapping_function
        (...)

    def make_instance(self, instance_data, input_grid, output_grid, wavelength):
        (...) # clever resampling stuff
        fast_axis_orientation = self.manufacturing_map(fast_axis_orientation) <-- the important part
        (...) 

The current issue is that the manufacturing mapping function as defined in self can't be called. The AgnosticOpticalElement gets the instance data (line 607, in get_instance_data) and then tries to hash the arguments of the function (line 323, in _get_cache_keys). The issue is that fields are an unhashable type.

The function in self also gets a different call signature according to my vscode linter. It shows that the call signature goes from
(Field) -> Field to (input_grid, output_grid, wavelegnth) -> Any.

If I use a global overwrite it works fine but thats quite ugly and really hacky and I don't like it.
Is there a neat way to do this?

Cheers,
Tom

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

No branches or pull requests

1 participant