def calculate_trial(self, simulation, engine): params = simulation.parameters src_plane = params.source_plane radius = params.quasar.radius.to(params.eta_0) dims = src_plane.dimensions zv = zero_vector('rad') results = [] for k in simulation.keys: if k == 'magmap': resolution = simulation['magmap'].resolution pr = PixelRegion(zv, dims, resolution).to(params.eta_0) ret = engine.query_region(pr, radius) results.append(ret) if k == 'momentmap': resolution = simulation['moment'].resolution result_dump = np.ndarray((6, resolution.x, resolution.y)) for i in range(6): pr = PixelRegion(zv, dims, resolution).to(params.eta_0) engine.calculation_delegate.setMoment(i) result_dump[i, :] = engine.query_region(pr, radius) results.append(result_dump) if k == 'lightcurves': region = Region(zv, dims) lines = simulation['lightcurves'].lines(region) scaled = np.array( list(map(lambda line: line.to(params.eta_0).value, lines))) ret = engine.query_points(scaled, radius) results.append(ret) if k == 'causticmap': resolution = simulation['causticmap'].resolution pr = PixelRegion(zv, dims, resolution).to(params.eta_0) ret = engine.query_region(pr, radius) results.append(ret) return results
def __init__(self, simulation, data): sp = simulation.parameters.source_plane theta_E = simulation.parameters.theta_E r = simulation['causticmap'].resolution self._source_plane = PixelRegion(zero_vector(theta_E), sp.dimensions.to(theta_E), r) self._data = data
def __init__(self, simulation, data): sp = simulation.parameters.source_plane theta_E = simulation.parameters.theta_E r = simulation['magmap'].resolution self._source_plane = PixelRegion(zero_vector(theta_E), sp.dimensions.to(theta_E), r) self._data = np.flip(data, 1) self._scaling = 1
def to_microParams( self, pcnt_stars: float, image_center: Vec2D, minor_axis: u.Quantity, star_generator: MassFunction) -> 'MicrolensingParameters': bounding_box = Region( zero_vector('uas'), Vec2D(minor_axis.value, minor_axis.value, minor_axis.unit)) return MicrolensingParameters(self.quasar, self.lens, pcnt_stars, image_center, self.ray_region.resolution, bounding_box, star_generator)
def QSO2237_ImageC(root_rays, percent_stars): from mirage.util import Vec2D, Region, zero_vector qso = QSO2237() src_plane = Vec2D(40, 40, qso.theta_E) qso.quasar.update(radius=80 * qso.quasar.r_g) center = zero_vector('rad') src_plane = Region(center, src_plane) img_center = Vec2D(1.4, 1.4, 'arcsec') ray_count = Vec2D(int(root_rays), int(root_rays)) return MicrolensingParameters(qso.quasar, qso.lens, percent_stars, img_center, ray_count, src_plane)
def get_object(self,*args,**kwargs): from mirage.parameters import Parameters, MicrolensingParameters, Quasar, Lens from mirage.util import Vec2D, PolarVec, PixelRegion, zero_vector from mirage.calculator import getMassFunction #First, pull out everyhing a micro and macro object needs. #Pull out values for special units first try: lRedshift = self.lRedshiftInput.value() qRedshift = self.qRedshiftInput.value() qMass = self.qMassInput.value()*u.solMass vDispersion = self.vDispersionInput.value()*u.km/u.s r_g, theta_E, xi = Parameters.special_units(qRedshift,lRedshift,qMass) einstein_radius = Parameters.static_einstein_radius(vDispersion,qRedshift,lRedshift) with u.add_enabled_units([r_g,theta_E,einstein_radius]): #Now I can continue to pull out values and not have a unit problem. ellipR, ellipTheta = self.ellipRInput.value(), self.ellipThetaInput.value() shearR, shearTheta = self.shearRInput.value(), self.shearThetaInput.value() qRadius = self.qRadiusInput.value()*UserInputWidget.unitFromString( self.qRadiusUnit.currentText(),r_g,theta_E) rayRegionLength = self.rootRayInput.value() shear = PolarVec(shearR,shearTheta) ellip = PolarVec(ellipR, ellipTheta) lens = Lens(lRedshift, vDispersion, shear, ellip) quasar = Quasar(qRedshift, qRadius, qMass) rayRegion = PixelRegion(zero_vector('arcsec'), Vec2D(1.4,1.4,einstein_radius), Vec2D(rayRegionLength,rayRegionLength)) macro_parameters = Parameters(quasar,lens,rayRegion) if self.enableMicrolensing.isChecked(): x,y = [float(v) for v in self.imgLocInput.text()[1:-1].split(",")] imgLocation = Vec2D(x,y,'arcsec') minorAxis = self.sPlaneDimInput.value()*UserInputWidget.unitFromString( self.sPlaneDimUnit.currentText(),r_g,theta_E) mass_fn = None mass_fn_seed = self.imfSeedInput.value() if self.imfInput.currentText() == "Custom": mass_fn = ParametersWidget._mk_mass_fn(self.imfPowersInput.text(), self.imfStepsInput.text(), self.imfAgingInput.text()) else: mass_fn = self.imfInput.currentText() star_generator = getMassFunction(mass_fn_seed,mass_fn) micro_params = macro_parameters.to_microParams(self.pcntStarsInput.value(), imgLocation, minorAxis, star_generator) return micro_params else: return macro_parameters except: UserInputWidget.warn_user("Error constructing the Parameters object. Please validate input and try again.")
def starry_region(self): radius = self.ray_region.dimensions.x * 0.6 center = zero_vector("rad") area = CircularRegion(center, radius) return area
def to_macroParams(self, pixels=Vec2D(2000, 2000)): region_dims = zero_vector( 'arcsec') + self.einstein_radius.to('arcsec') * 2.0 new_region = PixelRegion(zero_vector('arcsec'), region_dims, pixels) params = Parameters(self.quasar, self.lens, new_region) return params