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

No Transient Source #370

Open
MickaelRigault opened this issue May 10, 2023 · 8 comments
Open

No Transient Source #370

MickaelRigault opened this issue May 10, 2023 · 8 comments

Comments

@MickaelRigault
Copy link

Hello,

I was wondering if it would be possible to implement a simple ConstantSource that is a Source but with no phase. That could for instance be a Star. It would only need a spectra.

Worse case scenario I could create a Source and then give phase=0 all the time, but that is a not so elegant.

Cheers

@MickaelRigault
Copy link
Author

something like that I think work but is not nice

class ConstantSource(  sncosmo.TimeSeriesSource ):
    
    def __init__(self, wave, flux, name=None, version=None):
        # 
        nphase_bins = 2
        phase = np.linspace(-1., 1., nphase_bins)
        # w
        return super().__init__(phase, wave, np.repeat(flux[None,:], nphase_bins, axis=0), 
                                name=name, version=version, time_spline_degree=1)
    
    def bandmag(self, band, magsys):
        return super().bandmag(band, magsys, 0)
    
    def bandflux(self, band, zp=None, zpsys=None):
        """ """
        return super().bandflux( band, phase=0, zp=None, zpsys=None)
    
    def flux(self, wave):
        """ """
        return super().flux(0, wave) 

@benjaminrose
Copy link
Member

Initially, I like the idea, but what is the story behind this feature? What would people want to accomplish with a constant source?

@MickaelRigault
Copy link
Author

MickaelRigault commented May 12, 2023

I am writting a simulation tool. I am using sncosmo to simulate the transients, and I would like to be able to simulate stars too.

@benjaminrose
Copy link
Member

I wonder if it would be easier to flip the hierarchy, have sncosmo.TimeSeriesSource inherit from a new sncosmo. ConstantSource. Thoughts?

@MickaelRigault
Copy link
Author

That is exactly what needs to be done, but it changes the fundamental spirit of some core functions of sncosmo that expect phase_or_time.

But indeed the hierarchy should be something like

Source # very very generic

ConstantSource( Source ) # flux depend on band no time

VariableSource(Source ) # flux depend on band and time or Period

PeriodicSource( VariableSource) # like Cepheids !

Star( ConstantSource ) # here we could imaging having the calspec as default template

VariableSource would then be what is currently called Source

so TimeSeriesSource( VariableSource )

@benjaminrose
Copy link
Member

I have been thinking that SNCosmo could transition to a broader transient package. A change like this would need to be a new major release. We would also need to figure out how SNCosmo differs from other simulation tools like galsim. I wonder if it is best to let galsim focus on static sources, and we focus on transients.

@MickaelRigault
Copy link
Author

Then a periodic variable source would be enough. I may already have a Source class that may do the job. Need some time to check all aspects

@benjaminrose
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants