Search code examples
yamlgalsim

How to import angle values from a catalog into GalSim


I'm trying to import galaxy values (Sersic index, half light radius, etc) from an external ascii file in to GalSim. I'm having trouble reading in the position angle value 'beta', and would like to know if this is possible using the YAML format.

When I try I get the error message:

galsim.errors.GalSimConfigValueError: Invalid value_type specified for parameter beta with type=Catalog. Value <class 'coord.angle.Angle'> not in (<class 'float'>, <class 'int'>, <class 'bool'>, <class 'str'>)

I realise that I'm getting this error message because I'm unable to append the string 'deg' after the input to specify that the units of this input are in degrees.

I've tried adding 'deg' directly in to the input catalogue (inside "" speech marks), with no success. I've also tried adding 'deg' after the catalogue read statement directly in the code, also to no success.

A minimum working example is below. This relies on a file named 'input.dat' in the same directory with a single number inside (45, for example). Then, save the code below as 'test.yaml' and run on the command line as $ galsim test.yaml:

gal :
    type : Sersic
    n : 1
    half_light_radius : 1
    flux : 1
    ellip : 
        type : QBeta 
        q : 0.5
        beta : { type : Catalog , col : 0 }

input :
    catalog :
        file_name : input.dat

I expect to be able to read in beta position angle arguments from an input ascii catalogue and have them replicated in the output galaxy profiles. The above MWE should produce a small postage stamp image of a moderately elliptical galaxy at a position angle of 45 degrees (or whatever number is placed inside 'input.dat'.

Thank you in advance for any help or advice on this front.


Solution

  • Try this:

    gal :
        type : Sersic
        n : 1
        half_light_radius : 1
        flux : 1
        ellip : 
            type : QBeta 
            q : 0.5
            beta : 
                type: Radians
                theta: { type : Catalog , col : 0 }
    
    input :
        catalog :
            file_name : input.dat
    

    There is also a Degrees type that works the same way if your catalog columns list the angle in degrees.