当前位置: 首页>>代码示例>>Python>>正文


Python quanta.quantity函数代码示例

本文整理汇总了Python中pyrap.quanta.quantity函数的典型用法代码示例。如果您正苦于以下问题:Python quantity函数的具体用法?Python quantity怎么用?Python quantity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了quantity函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: enu2itrf

    def enu2itrf(self, antennas=None, lon=None, lat=None):
        """ Converts a list of ENU positions to ITRF positions. 
            Requires a reference positions (lon,lat) in radians. 
           
            Returns the ITRF reference position and the ITRF list of positions.
        """
        
        dm  = pyrap.measures.measures()
        
        antennas = self.antennas if antennas is None else antennas
        lon = lon or self.lon
        lat = lat or self.lat
        
        # convtert reference position to itrf system
        refpos_wgs84 = dm.position('wgs84', dq.quantity(lon, 'rad'),
                       dq.quantity(lat, 'rad'))
        refpos = dm.measure(refpos_wgs84, 'itrf')

        lon,lat,rad = [ refpos[x]['value'] for x in 'm0 m1 m2'.split() ]

        xyz0 = rad*numpy.array( [math.cos(lat)*math.cos(lon),
                        math.cos(lat)*math.sin(lon), math.sin(lat)])
        
        # 3x3 transformation matrix. Each row is a normal vector, i.e the rows are (dE,dN,dU)
        xform = numpy.array([
            [-math.sin(lon), math.cos(lon), 0],
            [-math.cos(lon)*math.sin(lat), -math.sin(lon)*math.sin(lat), math.cos(lat)],
            [math.cos(lat)*math.cos(lon), math.cos(lat)*math.sin(lon), math.sin(lat)]
])
        antennas = numpy.array(antennas)
        xyz = xyz0[numpy.newaxis,:] + antennas.dot(xform)

        return xyz0,xyz
开发者ID:Sebokolodi,项目名称:simms,代码行数:33,代码来源:uvgen.py

示例2: riseset

 def riseset(self, crd, ev="5deg"):
     a = self.rise(crd, ev)
     if isinstance(a, str):
         a = a.split()
         return { "rise": { "last": a[0], "utc": a[0] },
                  "set" : { "last": a[1], "utc": a[1] },
                  "solved": False }
     ofe = self.measure(self._framestack["epoch"], "utc")
     if not is_measure(ofe):
         ofe = self.epoch('utc', 'today')
     x = a.copy()
     for k in x.keys():
         x[k] = self.measure(self.epoch("last", dq.totime(a[k]),
                                        off=self.epoch("r_utc",
                                                       (dq.quantity(ofe["m0"]) + dq.quantity("0.5d")))),
                             "utc")
     return { "rise": { "last": self.epoch("last",
                                           dq.totime(a["rise"])),
                        "utc": x["rise"] },
              
              "set": { "last": self.epoch("last",
                                          dq.totime(a["set"])),
                        "utc": x["set"] },
              "solved" : True
              }
开发者ID:lbaehren,项目名称:lofarsoft,代码行数:25,代码来源:__init__.py

示例3: get_time_range

def get_time_range(start_time,end_time,timestep,time_in_sec,TIME_OFFSET=0):
    if HAS_PYRAP:
      try:
        start_time = qu.quantity(start_time).get_value()
        end_time = qu.quantity(end_time).get_value()
        print ('**** specified start and end time ', start_time, end_time)
        reference_time = start_time * 86400.0 - TIME_OFFSET
        st = reference_time - timestep 
        et = end_time * 86400.0 +  timestep + TIME_OFFSET
        #print "getting string",reference_time
        str_start_time =  obtain_observation_year_month_day_hms(reference_time)
        timerange= [st, et]
      except:
        print ('no time range given')
        print ('exiting')
        return -1,-1,-1
    elif HAS_EPHEM:
      if time_in_sec:
        dublin_start = start_time / 86400.0 -15019.5
        dublin_end = end_time / 86400.0 -15019.5
        start_time = ephem.julian_date(ephem.Date(dublin_start)) - 2400000.5
        end_time = ephem.julian_date(ephem.Date(dublin_end)) - 2400000.5
      else:
        start_time = ephem.julian_date(ephem.Date(start_time)) - 2400000.5
        end_time = ephem.julian_date(ephem.Date(end_time)) - 2400000.5
      print ('ephem start and end time ', start_time, end_time)
      reference_time = start_time * 86400.0 - TIME_OFFSET
      st = reference_time - timestep 
      et = end_time * 86400.0 + timestep + TIME_OFFSET
      str_start_time =  obtain_observation_year_month_day_hms(reference_time)
      timerange= [st, et]
    else:
      print ('unable to get time range so exiting!')
      return -1,-1,-1
    return timerange,str_start_time,reference_time
开发者ID:AHorneffer,项目名称:RMextract,代码行数:35,代码来源:PosTools.py

示例4: direction

 def direction(self, rf='', v0='0..', v1='90..', off=False):
     loc = { 'type': 'direction' , 'refer':  rf}
     loc['m0'] = dq.quantity(v0)
     loc['m1'] = dq.quantity(v1)
     if is_measure(off):
         if not off['type'] == "direction":
             raise TypeError('Illegal offset type specified.')
         loc["offset"] = off
     return self.measure(loc, rf)
开发者ID:lbaehren,项目名称:lofarsoft,代码行数:9,代码来源:__init__.py

示例5: print_facet_centre_list

def print_facet_centre_list(facet_centres, num_facet_centres):
    if num_facet_centres != 0:
        print "REQUESTED FACET CENTRES:"
        for i, c in enumerate(facet_centres):
            print "\tFACET %d RA: %s DEC: %s" % (
                i,
                quantity(c[0], "arcsec").get("deg"),
                quantity(c[1], "arcsec").get("deg"),
            )
开发者ID:jfunction,项目名称:bullseye,代码行数:9,代码来源:facet_list_parser.py

示例6: earthmagnetic

 def earthmagnetic(self, rf='', v0='0G', v1='0..', v2='90..', off=False):
     loc = { 'type': "earthmagnetic", 'refer': rf }
     loc['m0'] = dq.quantity(v0)
     loc['m1'] = dq.quantity(v1)
     loc['m2'] = dq.quantity(v2)
     if is_measure(off):
         if not off['type'] == "earthmagnetic":
             raise TypeError('Illegal offset type specified.')
         loc["offset"] = off
     return self.measure(loc, rf)
开发者ID:lbaehren,项目名称:lofarsoft,代码行数:10,代码来源:__init__.py

示例7: todoppler

 def todoppler(self, rf, v0, rfq=False):
     if is_measure(rfq) and rfq['type'] == 'frequency':
         rfq = dq.from_dict(rfq['m0'])
     if is_measure(v0):
         if v0['type'] == 'radialvelocity':
             return self.todop(v0, dq.to_dict(dq.quantity(1.,'Hz')))
         elif v0['type'] == 'frequency' and  isinstance(rfq, dq._quanta.Quantity) \
                  and rfq.conforms(dq.quantity('Hz')):
             return self.todop(v0, dq.to_dict(rfq))
         else:
             raise TypeError('Illegal Doppler or rest frequency specified')
     else:
         raise TypeError('Illegal Frequency specified')
开发者ID:lbaehren,项目名称:lofarsoft,代码行数:13,代码来源:__init__.py

示例8: parallactic_angles

def parallactic_angles(times, antenna_positions, field_centre):
    """
    Computes parallactic angles per timestep for the given
    reference antenna position and field centre.

    Arguments:
        times: ndarray
            Array of unique times with shape (ntime,),
            obtained from TIME column of MS table
        antenna_positions: ndarray of shape (na, 3)
            Antenna positions, obtained from POSITION
            column of MS ANTENNA sub-table
        field_centre : ndarray of shape (2,)
            Field centre, should be obtained from MS PHASE_DIR

    Returns:
        An array of parallactic angles per time-step

    """
    import pyrap.quanta as pq

    try:
        # Create direction measure for the zenith
        zenith = pm.direction('AZEL','0deg','90deg')
    except AttributeError as e:
        if pm is None:
            raise ImportError("python-casacore import failed")

        raise

    # Create position measures for each antenna
    reference_positions = [pm.position('itrf',
        *(pq.quantity(x,'m') for x in pos))
        for pos in antenna_positions]

    # Compute field centre in radians
    fc_rad = pm.direction('J2000',
        *(pq.quantity(f,'rad') for f in field_centre))

    return np.asarray([
            # Set current time as the reference frame
            pm.do_frame(pm.epoch("UTC", pq.quantity(t, "s")))
            and
            [   # Set antenna position as the reference frame
                pm.do_frame(rp)
                and
                pm.posangle(fc_rad, zenith).get_value("rad")
                for rp in reference_positions
            ]
        for t in times])
开发者ID:ska-sa,项目名称:montblanc,代码行数:50,代码来源:parallactic_angles.py

示例9: printJones

def printJones(stnName,obsTimes,srcDir,freqs,model):
    print "Frequency","Time","J00","J01","J10","J11"
    for freq in freqs:
        Jn=getJonesByAntFld(model,obsTimes,stnName,srcDir,freq)
        #plotJonesGnuplot(quantity(obsTimes.get_value()[0],obsTimes.get_unit()).formatted("YMD"),stepTime.seconds,Jn)
        for ti in range(0,len(obsTimes.get_value() )):
            print freq, quantity(obsTimes.get_value()[ti],obsTimes.get_unit()).formatted("YMD"), Jn[ti,0,0], Jn[ti,0,1],Jn[ti,1,0],Jn[ti,1,1]
开发者ID:2baOrNot2ba,项目名称:mscorpol,代码行数:7,代码来源:antennaJones.py

示例10: plotJones

def plotJones(stnName,obsTimes,freqs):
    #frequencys=np.linspace(0,100e6,512)
    #freqs=frequencys[150:350]
    timespy=[datetime.fromtimestamp(quantity(t,'d').to_unix_time()) for t in obsTimes.get_value()]
    freq=freqs[0]
    Jn=getJonesByAntFld(model,obsTimes,stnName,srcDir,freq)
    p_ch = np.abs(Jn[:,0,0].squeeze())**2+np.abs(Jn[:,0,1].squeeze())**2
    q_ch = np.abs(Jn[:,1,1].squeeze())**2+np.abs(Jn[:,1,0].squeeze())**2
    #For testing purposes:
    #p_ch = np.real(Jn[:,0,1].squeeze())
    #q_ch = np.real(Jn[:,0,1].squeeze())
    #In dB:
    p_ch = 10*np.log10(p_ch)
    q_ch = 10*np.log10(q_ch)
    
    plt.figure()
    plt.subplot(211)
    plt.plot(timespy, p_ch)
    plt.title('p channel')
    #plt.clim(-9, -3)
    plt.subplot(212)
    plt.plot(timespy, q_ch)
    plt.title('q-channel')
    #plt.clim(-9, -3)
    plt.xlabel('Time')
    plt.show()
开发者ID:2baOrNot2ba,项目名称:mscorpol,代码行数:26,代码来源:antennaJones.py

示例11: on_mouse_move

	def on_mouse_move(self,widget,event):
		if self._low_res_image != None: 
			sbrMain = self._builder.get_object("sbrMain")
			sbrMain.remove_all(sbrMain.get_context_id("CursorPos"))
			handle = self._builder.get_object("cvsLowRes")
			handle.queue_draw()
			rect = handle.get_allocation()
                        img_height = self._low_res_image.get_height()
                        img_width = self._low_res_image.get_width()
                        
                        self._l_pos = int(event.x/float(rect.width) * img_width) 
			self._m_pos = int(event.y/float(rect.height) * img_height) 
			
			sbrMain.push(sbrMain.get_context_id("CursorPos"),"Pixel position: (x,y) = (%d,%d), (ra,dec) = (%s,%s)" % (self._l_pos, self._m_pos,
							    		 quantity(quantity(self._phase_centres[self._field_id,0,0],"rad").get_value("arcsec") + (-self._l_pos + img_width/2)*self._img_cell_l,"arcsec").get("deg").formatted("[+-]dd.mm.ss.t.."),
							    		 quantity(quantity(self._phase_centres[self._field_id,0,1],"rad").get_value("arcsec") + (-self._m_pos + img_height/2)*self._img_cell_m,"arcsec").get("deg").formatted("[+-]dd.mm.ss.t..")))
开发者ID:ratt-ru,项目名称:bullseye,代码行数:16,代码来源:frmMain.py

示例12: updateMSmetadata

def updateMSmetadata(msfile):
  #Update history to show that this script has modified original data
  tms = pt.table(msfile,readonly=False,ack=False)
  th = pt.table(tms.getkeyword('HISTORY'), readonly=False, ack=False)
  nr=th.nrows()
  th.addrows(1)
  tr=th.row()
  tr.put(nr,{'TIME': quantity('today').get('s').get_value(),
             'OBSERVATION_ID':0,
             'MESSAGE': 'Applied polarization modifications',
             'PRIORITY': 'NORMAL',
             'ORIGIN': '%s: version = %s' % (__file__,__version__),
             'OBJECT_ID':0, 
             'APPLICATION':__file__,
             'CLI_COMMAND':sys.argv,
             'APP_PARAMS': ['']})

  if not options.linear:
     #Change metadata information to be circular feeds
     feed = pt.table(tms.getkeyword('FEED'),readonly=False,ack=False)
     for tpart in feed.iter('ANTENNA_ID'):
      tpart.putcell('POLARIZATION_TYPE',0,['R','L'])

     polariz = pt.table(tms.getkeyword('POLARIZATION'),readonly=False,ack=False)
     polariz.putcell('CORR_TYPE',0,[5,6,7,8])
     tms.close()
开发者ID:2baOrNot2ba,项目名称:mscorpol,代码行数:26,代码来源:mscorpol.py

示例13: epoch

 def epoch(self, rf='', v0='0.0d', off=False):
     loc = { 'type': 'epoch' , 'refer':  rf}
     loc['m0'] = dq.quantity(v0)
     if is_measure(off):
         if not off['type'] == "epoch":
             raise TypeError('Illegal offset type specified.')        
         loc["offset"] = off
     return self.measure(loc, rf)
开发者ID:lbaehren,项目名称:lofarsoft,代码行数:8,代码来源:__init__.py

示例14: insert_grid_points

def insert_grid_points(survey, filename, calibrator=False):
    with open(filename, 'r') as f:
        lines = f.readlines()

    for line in lines:
        split_string = line.split(None, 3)
        name = split_string[0]
        ra = quantity(split_string[1]).get_value('rad')
        dec = quantity(split_string[2].replace(":", ".", 2)).get_value('rad')
        if len(split_string) == 4:
            description = split_string[3].strip()
        else:
            description = ""
        f = Field.objects.create(
            name=name, ra=ra, dec=dec, description=description,
            survey=survey, calibrator=calibrator
        )
开发者ID:jdswinbank,项目名称:lofar-obsdb,代码行数:17,代码来源:create_survey.py

示例15: tofrequency

 def tofrequency(self, rf, v0, rfq):
     if is_measure(rfq) and rfq['type'] == 'frequency':
         rfq = dq.from_dict(rfq['m0'])
     if is_measure(v0) and  v0['type'] == 'doppler' \
            and  isinstance(rfq, dq._quanta.Quantity) \
            and  rfq.conforms(dq.quantity('Hz')):
         return self.doptofreq(v0, rf, dq.to_dict(rfq))
     else:
         raise TypeError('Illegal Doppler or rest frequency specified')
开发者ID:lbaehren,项目名称:lofarsoft,代码行数:9,代码来源:__init__.py


注:本文中的pyrap.quanta.quantity函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。