Changeset 33


Ignore:
Timestamp:
May 20, 2014 3:23:45 PM (10 years ago)
Author:
JohnLightfoot
Message:

various improvements

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/skygenerator.py

    r17 r33  
    55import numpy as np
    66import scipy.constants as sc
     7
     8import common.commonobjects as co
    79
    810def black_body(temperature, wavenumber):
     
    3840        spatial_axis = beamsgenerator['spatial axis [arcsec]']
    3941
    40         # oversampling factor
    41 #        oversample = 10
    42         oversample = 1
    43 
    44 #        print 'creating sky model with spatial dims [%s,%s] spectral dim %s',\
    45 #          (oversample * npix, oversample * npix, nspec)
    46 #        print 'spatial oversampling: %s' % oversample
    47         skymodel = np.zeros([npix, npix, nspec], np.float)
     42        # skymodel is complex so that its fft can hold truncated version
     43        # of infinitesimally sampled map - does that make sense?
     44        skymodel = np.zeros([npix, npix, nspec], np.complex)
    4845
    4946        sky = self.parameters['substages']['Sky']
     
    8380
    8481            if type.upper().strip() == 'POINT':
    85                 print 'creating point source'
    8682                source_spectrum = self._create_point_source(xpos, ypos,
    8783                  temperature,
     
    9490            self.result['sources'][sourcenum]['spectrum'] = source_spectrum
    9591
    96         print 'sources', self.result['sources']
    9792        self.result['sky model'] = skymodel
    9893        self.result['spatial axis'] = spatial_axis
     
    115110            return
    116111
    117         # calculate fourier phase shift to move point at [0,0] to [rowpos, colpos]
     112        # calculate fourier phase shift to move point at [0,0] to
     113        # [rowpos, colpos]
    118114        shiftx = np.zeros([nx], np.complex)
    119115        shiftx[:nx/2] = np.arange(nx/2, dtype=np.complex)
     
    135131        # sensitivity and source emissivity
    136132        bbmod = np.zeros(np.shape(frequency_axis))
    137         print 'frequency axis', frequency_axis
    138133        # ignore floating point errors
    139134        old_settings = np.seterr(all='ignore')
     
    141136            # simulate real-life 'rounded' cutoffs numerically 
    142137            f1 = 1.0 / (1.0 + pow(cutoffmin/wn, 18) + pow(wn/cutoffmax, 24))
    143             print pow(cutoffmin/wn,18), pow(wn/cutoffmax,24)
    144             print temperature, wn, black_body(temperature, wn), f1, emissivity
    145138            bbmod[iwn] = black_body(temperature, wn) * f1 * emissivity
    146139        # restore fp behaviour
     
    163156            skymodel[:,:,iwn] += temp
    164157
    165         return bbmod
     158        # return spectrum
     159        axis = co.Axis(data=frequency_axis, title='wavenumber', units='cm-1')
     160        spectrum = co.Spectrum(data=bbmod, axis=axis, title='Source spectrum',
     161          units='W sr-1 m-2 Hz-1')
     162
     163        return spectrum
    166164
    167165    def __repr__(self):
Note: See TracChangeset for help on using the changeset viewer.