idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
47,800 | def parse ( self , filename ) : filehandle = storage . open_vos_or_local ( filename , "rb" ) assert filehandle is not None , "Failed to open file {} " . format ( filename ) filestr = filehandle . read ( ) filehandle . close ( ) assert filestr is not None , "File contents are None" observations = self . _parse_observati... | Parses a file into an AstromData structure . |
47,801 | def write_headers ( self , observations , sys_header ) : if self . _header_written : raise AstromFormatError ( "Astrom file already has headers." ) self . _write_observation_list ( observations ) self . _write_observation_headers ( observations ) self . _write_sys_header ( sys_header ) self . _write_source_header ( ) s... | Writes the header part of the astrom file so that only the source data has to be filled in . |
47,802 | def write_astrom_data ( self , astrom_data ) : self . write_headers ( astrom_data . observations , astrom_data . sys_header ) self . _write_source_data ( astrom_data . sources ) | Writes a full AstromData structure at once . |
47,803 | def reference_source_point ( self ) : xref = isinstance ( self . xref , Quantity ) and self . xref . value or self . xref yref = isinstance ( self . yref , Quantity ) and self . yref . value or self . yref return xref + self . x_ref_offset , yref + self . y_ref_offset | The location of the source in the reference image in terms of the current image coordinates . |
47,804 | def get_coordinate_offset ( self , other_reading ) : my_x , my_y = self . reference_source_point other_x , other_y = other_reading . reference_source_point return my_x - other_x , my_y - other_y | Calculates the offsets between readings coordinate systems . |
47,805 | def from_source_reference ( expnum , ccd , x , y ) : image_uri = storage . dbimages_uri ( expnum = expnum , ccd = None , version = 'p' , ext = '.fits' , subdir = None ) logger . debug ( 'Trying to access {}' . format ( image_uri ) ) if not storage . exists ( image_uri , force = False ) : logger . warning ( 'Image not i... | Given the location of a source in the image create an Observation . |
47,806 | def _gradient_penalty ( self , real_samples , fake_samples , kwargs ) : import torch from torch . autograd import Variable , grad real_samples = real_samples . view ( fake_samples . shape ) subset_size = real_samples . shape [ 0 ] real_samples = real_samples [ : subset_size ] fake_samples = fake_samples [ : subset_size... | Compute the norm of the gradients for each sample in a batch and penalize anything on either side of unit norm |
47,807 | def mono ( self ) : if self . channels == 1 : return self x = self . sum ( axis = 1 ) * 0.5 y = x * 0.5 return AudioSamples ( y , self . samplerate ) | Return this instance summed to mono . If the instance is already mono this is a no - op . |
47,808 | def encode ( self , flo = None , fmt = 'WAV' , subtype = 'PCM_16' ) : flo = flo or BytesIO ( ) with SoundFile ( flo , mode = 'w' , channels = self . channels , format = fmt , subtype = subtype , samplerate = self . samples_per_second ) as f : if fmt == 'OGG' : factor = 20 chunksize = self . samples_per_second * factor ... | Return audio samples encoded as bytes given a particular audio format |
47,809 | def extend_with_default ( validator_class : Any ) -> Any : validate_properties = validator_class . VALIDATORS [ 'properties' ] def set_defaults ( validator : Any , properties : dict , instance : dict , schema : dict ) -> Iterator [ ValidationError ] : for prop , subschema in properties . items ( ) : if 'default' in sub... | Append defaults from schema to instance need to be validated . |
47,810 | def download_hdulist ( self , uri , ** kwargs ) : logger . debug ( str ( kwargs ) ) hdulist = None try : vobj = storage . vofile ( uri , ** kwargs ) try : fobj = cStringIO . StringIO ( vobj . read ( ) ) fobj . seek ( 0 ) hdulist = fits . open ( fobj ) except Exception as e : sys . stderr . write ( "ERROR: {}\n" . forma... | Downloads a FITS image as a HDUList . |
47,811 | def download_apcor ( self , uri ) : local_file = os . path . basename ( uri ) if os . access ( local_file , os . F_OK ) : fobj = open ( local_file ) else : fobj = storage . vofile ( uri , view = 'data' ) fobj . seek ( 0 ) str = fobj . read ( ) fobj . close ( ) apcor_str = str return ApcorData . from_string ( apcor_str ... | Downloads apcor data . |
47,812 | def from_string ( cls , rawstr ) : try : args = map ( float , rawstr . split ( ) ) except Exception as ex : import sys logger . error ( "Failed to convert aperture correction: {}" . format ( ex ) ) raise ex return cls ( * args ) | Creates an ApcorData record from the raw string format . |
47,813 | def htmIndex ( ra , dec , htm_level = 3 ) : import re if os . uname ( ) [ 0 ] == "Linux" : javabin = '/opt/java2/bin/java ' htm_level = htm_level verc_htm_cmd = javabin + '-classpath /usr/cadc/misc/htm/htmIndex.jar edu.jhu.htm.app.lookup %s %s %s' % ( htm_level , ra , dec ) for result in os . popen ( verc_htm_cmd ) . r... | Compute htm index of htm_level at position ra dec |
47,814 | def predict ( abg , date , obs = 568 ) : import orbfit import RO . StringUtil ( ra , dec , a , b , ang ) = orbfit . predict ( abg , date , obs ) obj [ 'RA' ] = ra obj [ 'DEC' ] = dec obj [ 'dRA' ] = a obj [ 'dDEC' ] = b obj [ 'dANG' ] = ang return obj | Run GB s predict using an ABG file as input . |
47,815 | def config_logging ( level ) : logger = logging . getLogger ( '' ) logger . setLevel ( level ) if level < logging . DEBUG : log_format = "%(asctime)s %(message)s" else : log_format = "%(asctime)s %(module)s : %(lineno)d %(message)s" sh = logging . StreamHandler ( ) sh . formatter = logging . Formatter ( fmt = log_form... | Configure the logging given the level desired |
47,816 | def exec_prog ( args ) : program_name = args [ 0 ] logging . info ( " " . join ( args ) ) output = subprocess . check_output ( args , stderr = subprocess . STDOUT ) if not os . access ( program_name + ".OK" , os . F_OK ) : logging . error ( "No {}.OK file?" . format ( program_name ) ) raise subprocess . CalledProcessEr... | Run a subprocess check for . OK and raise error if does not exist . |
47,817 | def stream ( self ) : if self . _stream is None : self . _stream = tempfile . NamedTemporaryFile ( delete = False ) try : self . _stream . write ( self . client . open ( self . filename , view = 'data' ) . read ( ) ) except : pass return self . _stream | the stream to write the log content too . |
47,818 | def client ( self ) : if self . _client is not None : return self . _client self . _client = vospace . client return self . _client | Send back the client we were sent or construct a default one . |
47,819 | def parse_string ( self , timestr , subfmts ) : components = ( 'year' , 'mon' , 'mday' ) defaults = ( None , 1 , 1 , 0 ) try : idot = timestr . rindex ( '.' ) except : fracday = 0.0 else : timestr , fracday = timestr [ : idot ] , timestr [ idot : ] fracday = float ( fracday ) for _ , strptime_fmt_or_regex , _ in subfmt... | Read time from a single string using a set of possible formats . |
47,820 | def _get_db_options ( args ) : import optik , getpass , sys from optik import OptionParser parser = OptionParser ( ) parser . add_option ( "-d" , "--database" , action = "store" , type = "string" , dest = "database" , default = "cfht" , help = "Name of the SYBASE database containing TABLE" , metavar = "FILE" ) parser .... | Parse through a command line of arguments to over - ride the values in the users . dbrc file . |
47,821 | def _get_db_connect ( dbSystem , db , user , password ) : if dbSystem == 'SYBASE' : import Sybase try : dbh = Sybase . connect ( dbSystem , user , password , database = db ) except : dbh = None elif dbSystem == 'MYSQL' : import MySQLdb try : dbh = MySQLdb . connect ( user = user , passwd = password , db = db , host = '... | Create a connection to the database specified on the command line |
47,822 | def download_cutout ( self , reading , focus = None , needs_apcor = False ) : logger . debug ( "Doing download_cutout with inputs: reading:{} focus:{} needs_apcor:{}" . format ( reading , focus , needs_apcor ) ) assert isinstance ( reading , SourceReading ) min_radius = config . read ( 'CUTOUTS.SINGLETS.RADIUS' ) if no... | Downloads a cutout of the FITS image for a given source reading . |
47,823 | def load_objects ( self , directory_name = None ) : if directory_name is not None : if directory_name == parameters . REAL_KBO_AST_DIR : kbos = parsers . ossos_discoveries ( all_objects = True , data_release = None ) else : kbos = parsers . ossos_discoveries ( directory_name , all_objects = False , data_release = None ... | Load the targets from a file . |
47,824 | def p2c ( self , p = None ) : if p is None : p = [ 0 , 0 ] x = ( p [ 0 ] - self . x1 ) * self . xscale + self . cx1 y = ( p [ 1 ] - self . y1 ) * self . yscale + self . cy1 return ( x , y ) | convert from plot to canvas coordinates . |
47,825 | def p2s ( self , p = None ) : if not p : p = [ 0 , 0 ] s = self . p2c ( p ) return self . c2s ( s ) | Convert from plot to screen coordinates |
47,826 | def tickmark ( self , x , y , size = 10 , orientation = 90 ) : ( x1 , y1 ) = self . p2c ( [ x , y ] ) x2 = x1 + size * math . cos ( math . radians ( orientation ) ) y2 = y1 - size * math . sin ( math . radians ( orientation ) ) self . create_line ( x1 , y1 , x2 , y2 ) | Draw a line of size and orientation at x y |
47,827 | def relocate ( self ) : name = self . SearchVar . get ( ) if self . kbos . has_key ( name ) : kbo = self . kbos [ name ] assert isinstance ( kbo , orbfit . Orbfit ) this_time = Time ( self . date . get ( ) , scale = 'utc' ) try : kbo . predict ( this_time ) self . recenter ( kbo . coordinate . ra . radian , kbo . coord... | Move to the position of self . SearchVar |
47,828 | def create_point ( self , xcen , ycen , size = 10 , color = 'red' , fill = None ) : if fill is None : fill = color ( x , y ) = self . p2c ( ( xcen , ycen ) ) x1 = x - size x2 = x + size y1 = y - size y2 = y + size self . create_rectangle ( x1 , y1 , x2 , y2 , fill = fill , outline = color ) | Plot a circle of size at this x y location |
47,829 | def current_pointing ( self , index ) : if self . current is not None : for item in self . pointings [ self . current ] [ 'items' ] : self . itemconfigure ( item , outline = "black" ) self . current = index for item in self . pointings [ self . current ] [ 'items' ] : self . itemconfigure ( item , outline = "blue" ) | set the color of the currently selected pointing to blue |
47,830 | def delete_pointing ( self , event ) : if self . current is None : return for item in self . pointings [ self . current ] [ 'items' ] : self . delete ( item ) self . delete ( self . pointings [ self . current ] [ 'label' ] [ 'id' ] ) del ( self . pointings [ self . current ] ) self . current = None | Delete the currently active pointing |
47,831 | def create_pointing ( self , event , label_text = None ) : x = self . canvasx ( event . x ) y = self . canvasy ( event . y ) ( ra , dec ) = self . c2p ( ( x , y ) ) this_camera = Camera ( ra = float ( ra ) * units . radian , dec = float ( dec ) * units . radian , camera = self . camera . get ( ) ) ccds = numpy . radian... | Plot the sky coverage of pointing at event . x event . y on the canvas . |
47,832 | def move_pointing ( self , event ) : ( ra , dec ) = self . c2p ( ( self . canvasx ( event . x ) , self . canvasy ( event . y ) ) ) closest = None this_pointing = None this_index = - 1 index = - 1 for pointing in self . pointings : index = index + 1 ds = pointing [ "camera" ] . separation ( ra , dec ) if this_pointing i... | Grab nearest pointing to event . x event . y and with cursor |
47,833 | def ossos_pointings ( self ) : match = re . match ( '(\d+)\D(\d+)' , self . expnum . get ( ) ) if match is not None : expnum = int ( match . group ( 1 ) ) ccd = int ( match . group ( 2 ) ) x = 2112 / 2.0 y = 4644 / 2.0 else : expnum = int ( str ( self . expnum . get ( ) ) ) ccd = 22 x = 1000 y = 4644 - 15 / 0.185 heade... | plot an OSSOS observation on the OSSOS plot . |
47,834 | def get_pointings ( self ) : self . camera . set ( "MEGACAM_40" ) ( ra1 , dec1 ) = self . c2p ( ( self . canvasx ( 1 ) , self . canvasy ( 1 ) ) ) ( ra2 , dec2 ) = self . c2p ( ( self . canvasx ( 480 * 2 ) , self . canvasy ( 360 * 2 ) ) ) ra_cen = math . degrees ( ( ra2 + ra1 ) / 2.0 ) dec_cen = math . degrees ( ( dec2 ... | Retrieve the MEGACAM pointings that overlap with the current FOV and plot . |
47,835 | def doplot ( self ) : w = self w . delete ( ALL ) w . coord_grid ( ) w . objList . delete ( 0 , END ) self . _plot ( ) | Clear the plot and then redraw it . |
47,836 | def ec2eq ( self ) : import math from math import sin , cos from math import asin as arcsin from math import atan2 as arctan2 from math import acos as arccos eb = self . eb el = self . el ob = math . radians ( 23.439281 ) dec = arcsin ( sin ( eb ) * cos ( ob ) + cos ( eb ) * sin ( ob ) * sin ( el ) ) sra = ( sin ( dec ... | Convert ecliptic coordinates to equatorial coordinates |
47,837 | def plot_line ( axes , fname , ltype ) : x = np . genfromtxt ( fname , unpack = True ) axes . plot ( x [ 0 ] , x [ 1 ] , ltype ) | plot the ecliptic plane line on the given axes . |
47,838 | def apmag_at_absmag ( H , d , phi = 1 ) : d_observer = 1. m_r = H + 2.5 * math . log10 ( ( d ** 4 ) / ( phi * d_observer ** 4 ) ) print ( "m_r = {:2.2f} for a H = {} TNO at {} AU at opposition." . format ( m_r , H , d ) ) return m_r | Calculate the apparent magnitude of a TNO given its absolute magnitude H for a given distance . |
47,839 | def scci_cmd ( host , userid , password , cmd , port = 443 , auth_method = 'basic' , client_timeout = 60 , do_async = True , ** kwargs ) : auth_obj = None try : protocol = { 80 : 'http' , 443 : 'https' } [ port ] auth_obj = { 'basic' : requests . auth . HTTPBasicAuth ( userid , password ) , 'digest' : requests . auth .... | execute SCCI command |
47,840 | def get_client ( host , userid , password , port = 443 , auth_method = 'basic' , client_timeout = 60 , ** kwargs ) : return functools . partial ( scci_cmd , host , userid , password , port = port , auth_method = auth_method , client_timeout = client_timeout , ** kwargs ) | get SCCI command partial function |
47,841 | def get_virtual_cd_set_params_cmd ( remote_image_server , remote_image_user_domain , remote_image_share_type , remote_image_share_name , remote_image_deploy_iso , remote_image_username , remote_image_user_password ) : cmd = _VIRTUAL_MEDIA_CD_SETTINGS % ( remote_image_server , remote_image_user_domain , remote_image_sha... | get Virtual CD Media Set Parameters Command |
47,842 | def get_virtual_fd_set_params_cmd ( remote_image_server , remote_image_user_domain , remote_image_share_type , remote_image_share_name , remote_image_floppy_fat , remote_image_username , remote_image_user_password ) : cmd = _VIRTUAL_MEDIA_FD_SETTINGS % ( remote_image_server , remote_image_user_domain , remote_image_sha... | get Virtual FD Media Set Parameters Command |
47,843 | def get_report ( host , userid , password , port = 443 , auth_method = 'basic' , client_timeout = 60 ) : auth_obj = None try : protocol = { 80 : 'http' , 443 : 'https' } [ port ] auth_obj = { 'basic' : requests . auth . HTTPBasicAuth ( userid , password ) , 'digest' : requests . auth . HTTPDigestAuth ( userid , passwor... | get iRMC report |
47,844 | def get_essential_properties ( report , prop_keys ) : v = { } v [ 'memory_mb' ] = int ( report . find ( './System/Memory/Installed' ) . text ) v [ 'local_gb' ] = sum ( [ int ( int ( size . text ) / 1024 ) for size in report . findall ( './/PhysicalDrive/ConfigurableSize' ) ] ) v [ 'cpus' ] = sum ( [ int ( cpu . find ( ... | get essential properties |
47,845 | def get_capabilities_properties ( d_info , capa_keys , gpu_ids , fpga_ids = None , ** kwargs ) : snmp_client = snmp . SNMPClient ( d_info [ 'irmc_address' ] , d_info [ 'irmc_snmp_port' ] , d_info [ 'irmc_snmp_version' ] , d_info [ 'irmc_snmp_community' ] , d_info [ 'irmc_snmp_security' ] ) try : v = { } if 'rom_firmwar... | get capabilities properties |
47,846 | def get_firmware_upgrade_status ( irmc_info , upgrade_type ) : host = irmc_info . get ( 'irmc_address' ) userid = irmc_info . get ( 'irmc_username' ) password = irmc_info . get ( 'irmc_password' ) port = irmc_info . get ( 'irmc_port' , 443 ) auth_method = irmc_info . get ( 'irmc_auth_method' , 'digest' ) client_timeout... | get firmware upgrade status of bios or irmc |
47,847 | def on_toggle_autoplay_key ( self ) : if self . autoplay_manager . is_running ( ) : self . autoplay_manager . stop_autoplay ( ) self . view . set_autoplay ( False ) else : self . autoplay_manager . start_autoplay ( ) self . view . set_autoplay ( True ) | The user has pressed the keybind for toggling autoplay . |
47,848 | def on_do_accept ( self , minor_planet_number , provisional_name , note1 , note2 , date_of_obs , ra , dec , obs_mag , obs_mag_err , band , observatory_code , comment ) : note1_code = note1 . split ( " " ) [ 0 ] note2_code = note2 . split ( " " ) [ 0 ] self . view . close_accept_source_dialog ( ) self . model . set_curr... | After a source has been mark for acceptance create an MPC Observation record . |
47,849 | def on_load_comparison ( self , research = False ) : cutout = self . model . get_current_cutout ( ) if research : cutout . comparison_image_index = None comparison_image = cutout . comparison_image if comparison_image is None : print "Failed to load comparison image: {}" . format ( cutout . comparison_image_list [ cuto... | Display the comparison image |
47,850 | def apply ( self , reboot = False ) : self . root . use_virtual_addresses = True self . root . manage . manage = True self . root . mode = 'new' self . root . init_boot = reboot self . client . set_profile ( self . root . get_json ( ) ) | Apply the configuration to iRMC . |
47,851 | def terminate ( self , reboot = False ) : self . root . manage . manage = False self . root . mode = 'delete' self . root . init_boot = reboot self . client . set_profile ( self . root . get_json ( ) ) | Delete VIOM configuration from iRMC . |
47,852 | def set_lan_port ( self , port_id , mac = None ) : port_handler = _parse_physical_port_id ( port_id ) port = self . _find_port ( port_handler ) if port : port_handler . set_lan_port ( port , mac ) else : self . _add_port ( port_handler , port_handler . create_lan_port ( mac ) ) | Set LAN port information to configuration . |
47,853 | def set_iscsi_volume ( self , port_id , initiator_iqn , initiator_dhcp = False , initiator_ip = None , initiator_netmask = None , target_dhcp = False , target_iqn = None , target_ip = None , target_port = 3260 , target_lun = 0 , boot_prio = 1 , chap_user = None , chap_secret = None , mutual_chap_secret = None ) : initi... | Set iSCSI volume information to configuration . |
47,854 | def set_fc_volume ( self , port_id , target_wwn , target_lun = 0 , boot_prio = 1 , initiator_wwnn = None , initiator_wwpn = None ) : port_handler = _parse_physical_port_id ( port_id ) fc_target = elcm . FCTarget ( target_wwn , target_lun ) fc_boot = elcm . FCBoot ( boot_prio = boot_prio , boot_enable = True ) fc_boot .... | Set FibreChannel volume information to configuration . |
47,855 | def _pad_former_ports ( self , port_handler ) : if not port_handler . need_padding ( ) : return for port_idx in range ( 1 , port_handler . port_idx ) : pad_handler = port_handler . __class__ ( port_handler . slot_type , port_handler . card_type , port_handler . slot_idx , port_handler . card_idx , port_idx ) if not sel... | Create ports with former port index . |
47,856 | def chunk_size_samples ( sf , buf ) : byte_depth = _lookup [ sf . subtype ] channels = sf . channels bytes_per_second = byte_depth * sf . samplerate * channels secs = len ( buf ) / bytes_per_second secs = max ( 1 , secs - 6 ) return int ( secs * sf . samplerate ) | Black magic to account for the fact that libsndfile s behavior varies depending on file format when using the virtual io api . |
47,857 | def encode ( number , alphabet ) : if not isinstance ( number , ( int , long ) ) : raise TypeError ( "Number must be an integer." ) base_n = "" sign = "" if number < 0 : sign = "-" number = - number if 0 <= number < len ( alphabet ) : return sign + alphabet [ number ] while number != 0 : number , i = divmod ( number , ... | Converts an integer to a base n string where n is the length of the provided alphabet . |
47,858 | def categorical ( x , mu = 255 , normalize = True ) : if normalize : mx = x . max ( ) x = np . divide ( x , mx , where = mx != 0 ) x = mu_law ( x ) x = ( x - x . min ( ) ) * 0.5 x = ( x * mu ) . astype ( np . uint8 ) c = np . zeros ( ( np . product ( x . shape ) , mu + 1 ) , dtype = np . uint8 ) c [ np . arange ( len (... | Mu - law compress a block of audio samples and convert them into a categorical distribution |
47,859 | def inverse_categorical ( x , mu = 255 ) : flat = x . reshape ( ( - 1 , x . shape [ - 1 ] ) ) indices = np . argmax ( flat , axis = 1 ) . astype ( np . float32 ) indices = ( indices / mu ) - 0.5 inverted = inverse_mu_law ( indices , mu = mu ) . reshape ( x . shape [ : - 1 ] ) return ArrayWithUnits ( inverted , x . dime... | Invert categorical samples |
47,860 | def synthesize ( self , duration , freqs_in_hz = [ 440. ] ) : freqs = np . array ( freqs_in_hz ) scaling = 1 / len ( freqs ) sr = int ( self . samplerate ) cps = freqs / sr ts = ( duration / Seconds ( 1 ) ) * sr ranges = np . array ( [ np . arange ( 0 , ts * c , c ) for c in cps ] ) raw = ( np . sin ( ranges * ( 2 * np... | Synthesize one or more sine waves |
47,861 | def synthesize ( self , duration , tick_frequency ) : sr = self . samplerate . samples_per_second tick = np . random . uniform ( low = - 1. , high = 1. , size = int ( sr * .1 ) ) tick *= np . linspace ( 1 , 0 , len ( tick ) ) samples = np . zeros ( int ( sr * ( duration / Seconds ( 1 ) ) ) ) ticks_per_second = Seconds ... | Synthesize periodic ticks generated from white noise and an envelope |
47,862 | def synthesize ( self , duration ) : sr = self . samplerate . samples_per_second seconds = duration / Seconds ( 1 ) samples = np . random . uniform ( low = - 1. , high = 1. , size = int ( sr * seconds ) ) return AudioSamples ( samples , self . samplerate ) | Synthesize white noise |
47,863 | def query_ssos ( self ) : self . _ssos_queried = True mpc_filename = self . save ( ) return self . builder . build_workunit ( mpc_filename ) | Use the MPC file that has been built up in processing this work unit to generate another workunit . |
47,864 | def save ( self ) : self . get_writer ( ) . flush ( ) mpc_filename = self . get_writer ( ) . get_filename ( ) self . get_writer ( ) . close ( ) self . _writer = None return mpc_filename | Update the SouceReading information for the currently recorded observations and then flush those to a file . |
47,865 | def get_writer ( self ) : if self . _writer is None : suffix = tasks . get_suffix ( tasks . TRACK_TASK ) try : base_name = re . search ( "(?P<base_name>.*?)\.\d*{}" . format ( suffix ) , self . filename ) . group ( 'base_name' ) except : base_name = os . path . splitext ( self . filename ) [ 0 ] mpc_filename_pattern = ... | Get a writer . |
47,866 | def _filter ( self , filename ) : return self . name_filter is not None and re . search ( self . name_filter , filename ) is None | return true if filename doesn t match name_filter regex and should be filtered out of the list . |
47,867 | def get_workunit ( self , ignore_list = None ) : if ignore_list is None : ignore_list = [ ] potential_files = self . get_potential_files ( ignore_list ) while len ( potential_files ) > 0 : potential_file = self . select_potential_file ( potential_files ) potential_files . remove ( potential_file ) if self . _filter ( p... | Gets a new unit of work . |
47,868 | def move_discovery_to_front ( self , data ) : readings = self . get_readings ( data ) discovery_index = self . get_discovery_index ( data ) reordered_readings = ( readings [ discovery_index : discovery_index + 3 ] + readings [ : discovery_index ] + readings [ discovery_index + 3 : ] ) self . set_readings ( data , reord... | Moves the discovery triplet to the front of the reading list . Leaves everything else in the same order . |
47,869 | def TAPQuery ( RAdeg = 180.0 , DECdeg = 0.0 , width = 1 , height = 1 ) : QUERY = ( ) QUERY = QUERY . format ( RAdeg , DECdeg , width , height ) data = { "QUERY" : QUERY , "REQUEST" : "doQuery" , "LANG" : "ADQL" , "FORMAT" : "votable" } url = "http://www.cadc.hia.nrc.gc.ca/tap/sync" print url , data return urllib . urlo... | Do a query of the CADC Megacam table . Get all observations insize the box . Returns a file - like object |
47,870 | def get_flipped_ext ( file_id , ccd ) : import MOPfits import os , shutil filename = MOPfits . adGet ( file_id , extno = int ( ccd ) ) if int ( ccd ) < 18 : tfname = filename + "F" shutil . move ( filename , tfname ) os . system ( "imcopy %s[-*,-*] %s" % ( tfname , filename ) ) os . unlink ( tfname ) if not os . access... | Given a list of exposure numbers and CCD get them from the DB |
47,871 | def get_file_ids ( object ) : import MOPdbaccess mysql = MOPdbaccess . connect ( 'cfeps' , 'cfhls' , dbSystem = 'MYSQL' ) cfeps = mysql . cursor ( ) sql = "SELECT file_id FROM measure WHERE provisional LIKE %s" cfeps . execute ( sql , ( object , ) ) file_ids = cfeps . fetchall ( ) return ( file_ids ) | Get the exposure for a particular line in the meausre table |
47,872 | def main ( ) : parser = argparse . ArgumentParser ( description = 'replace image header' ) parser . add_argument ( '--extname' , help = 'name of extension to in header' ) parser . add_argument ( 'expnum' , type = str , help = 'exposure to update' ) parser . add_argument ( '-r' , '--replace' , action = 'store_true' , he... | Do the script . |
47,873 | def handle_error ( self , error , download_request ) : if hasattr ( error , "errno" ) and error . errno == errno . EACCES : self . handle_certificate_problem ( str ( error ) ) else : self . handle_general_download_error ( str ( error ) , download_request ) | Checks what error occured and looks for an appropriate solution . |
47,874 | def get_current_observation_date ( self ) : header = self . get_current_cutout ( ) . hdulist [ - 1 ] . header mjd_obs = float ( header . get ( 'MJD-OBS' ) ) exptime = float ( header . get ( 'EXPTIME' ) ) mpc_date = Time ( mjd_obs , format = 'mjd' , scale = 'utc' , precision = config . read ( 'MPC.DATE_PRECISION' ) ) mp... | Get the date of the current observation by looking in the header of the observation for the DATE and EXPTIME keywords . |
47,875 | def parse_eff ( filename ) : blocks = [ ] block = { } with open ( filename ) as efile : for line in efile . readlines ( ) : if line . lstrip ( ) . startswith ( "#" ) : continue keyword = line . lstrip ( ) . split ( "=" ) [ 0 ] funcs = { 'square_param' : parse_square_param , 'rates' : rates } block [ keyword ] = funcs .... | Parse through Jean - Marcs OSSSO . eff files . The efficiency files comes in chunks meant to be used at different rates of motion . |
47,876 | def read ( keypath , configfile = None ) : if configfile in _configs : appconfig = _configs [ configfile ] else : appconfig = AppConfig ( configfile = configfile ) _configs [ configfile ] = appconfig return appconfig . read ( keypath ) | Reads a value from the configuration file . |
47,877 | def _cdata_header ( self , colsep = "|" ) : fields = self . fields header_lines = [ ] line = "" for fieldName in self . field_names : width = int ( fields [ fieldName ] [ 'attr' ] [ 'width' ] ) line += self . _entry ( fieldName , width , colsep ) header_lines . append ( line ) line = "" for fieldName in self . field_na... | Create a header for the CDATA section as a visual guide . |
47,878 | def _append_cdata ( self , coordinate ) : fields = self . fields sra = coordinate . ra . to_string ( units . hour , sep = ':' , precision = 2 , pad = True ) sdec = coordinate . dec . to_string ( units . degree , sep = ':' , precision = 1 , alwayssign = True ) coord = SkyCoord ( sra + " " + sdec , unit = ( units . hour ... | Append an target location to the ephemeris listing . |
47,879 | def gemini_writer ( self , f_handle ) : f_handle . write ( GEMINI_HEADER ) for coordinate in self . coordinates : date = coordinate . obstime . datetime . strftime ( '%Y-%b-%d %H:%M' ) [ : 17 ] f_handle . write ( " {:16} {:17.9f} {:27} {:+8.5f} {:+8.5f}\n" . format ( date , coordinate . obstime . jd , coordinate . t... | Write out a GEMINI formated OT ephemeris . This is just a hack of SSD Horizons output . |
47,880 | def intersect ( self , other ) : lowest_stop = min ( self . stop_hz , other . stop_hz ) highest_start = max ( self . start_hz , other . start_hz ) return FrequencyBand ( highest_start , lowest_stop ) | Return the intersection between this frequency band and another . |
47,881 | def bands ( self ) : if self . _bands is None : self . _bands = self . _compute_bands ( ) return self . _bands | An iterable of all bands in this scale |
47,882 | def Q ( self ) : return np . array ( list ( self . center_frequencies ) ) / np . array ( list ( self . bandwidths ) ) | The quality factor of the scale or the ratio of center frequencies to bandwidths |
47,883 | def get_slice ( self , frequency_band ) : index = frequency_band if isinstance ( index , slice ) : types = { index . start . __class__ , index . stop . __class__ , index . step . __class__ } if Hertz not in types : return index try : start = Hertz ( 0 ) if index . start is None else index . start if start < Hertz ( 0 )... | Given a frequency band and a frequency dimension comprised of n_samples return a slice using integer indices that may be used to extract only the frequency samples that intersect with the frequency band |
47,884 | def _hz_to_semitones ( self , hz ) : return np . log ( hz / self . _a440 ) / np . log ( self . _a ) | Convert hertz into a number of semitones above or below some reference value in this case A440 |
47,885 | def resolve ( object ) : import re sesame_cmd = 'curl -s http://cdsweb.u-strasbg.fr/viz-bin/nph-sesame/-oI?' + string . replace ( object , ' ' , '' ) f = os . popen ( sesame_cmd ) lines = f . readlines ( ) f . close ( ) for line in lines : if re . search ( '%J ' , line ) : result2 = line . split ( ) ra_deg = float ( re... | Look up the name of a source using a resolver |
47,886 | def handle_exit_code ( d , code ) : if code in ( d . DIALOG_CANCEL , d . DIALOG_ESC ) : if code == d . DIALOG_CANCEL : msg = "You chose cancel in the last dialog box. Do you want to " "exit this demo?" else : msg = "You pressed ESC in the last dialog box. Do you want to " "exit this demo?" if d . yesno ( msg ) == d . D... | Sample function showing how to interpret the dialog exit codes . |
47,887 | def main ( ) : try : demo ( ) except dialog . error , exc_instance : sys . stderr . write ( "Error:\n\n%s\n" % exc_instance . complete_message ( ) ) sys . exit ( 1 ) sys . exit ( 0 ) | This demo shows the main features of the pythondialog Dialog class . |
47,888 | def is_up ( coordinate , current_time ) : cfht . date = current_time . iso . replace ( '-' , '/' ) cfht . horizon = math . radians ( - 7 ) sun . compute ( cfht ) sun_rise = Time ( str ( sun . rise_time ) . replace ( '/' , '-' ) ) sun_set = Time ( str ( sun . set_time ) . replace ( '/' , '-' ) ) if current_time < sun_se... | Given the position and time determin if the given target is up . |
47,889 | def get_json ( self ) : viom_table = self . get_basic_json ( ) if self . slots : viom_table [ 'Slots' ] = { 'Slot' : [ s . get_json ( ) for s in self . slots . values ( ) ] } if self . manage : viom_table [ 'VIOMManage' ] = self . manage . get_json ( ) return viom_table | Create JSON data for AdapterConfig . |
47,890 | def get_json ( self ) : json = self . get_basic_json ( ) if self . onboard_cards : json [ 'OnboardControllers' ] = { 'OnboardController' : [ c . get_json ( ) for c in self . onboard_cards . values ( ) ] } if self . addon_cards : json [ 'AddOnCards' ] = { 'AddOnCard' : [ c . get_json ( ) for c in self . addon_cards . va... | Create JSON data for slot . |
47,891 | def get_json ( self ) : port = self . get_basic_json ( ) port . update ( { 'BootProtocol' : self . boot . BOOT_PROTOCOL , 'BootPriority' : self . boot . boot_prio , } ) boot_env = self . boot . get_json ( ) if boot_env : port . update ( boot_env ) if self . use_virtual_addresses and self . mac : port [ 'VirtualAddress'... | Create JSON data for LANPort . |
47,892 | def get_json ( self ) : port = self . get_basic_json ( ) port . update ( { 'BootProtocol' : self . boot . BOOT_PROTOCOL , 'BootPriority' : self . boot . boot_prio , } ) boot_env = self . boot . get_json ( ) if boot_env : port . update ( boot_env ) if self . use_virtual_addresses : addresses = { } if self . wwnn : addre... | Create FC port . |
47,893 | def get_json ( self ) : port = self . get_basic_json ( ) port [ 'Functions' ] = { 'Function' : [ f . get_json ( ) for f in self . functions . values ( ) ] } return port | Create JSON for CNA port . |
47,894 | def get_json ( self ) : json = self . get_basic_json ( ) for i in range ( len ( self . targets ) ) : self . targets [ i ] . set_index ( i + 1 ) json [ 'FCTargets' ] = { 'FCTarget' : [ t . get_json ( ) for t in self . targets ] } return { 'FCBootEnvironment' : json } | Create JSON for FCBootEnvironment . |
47,895 | def get_json ( self ) : if self . dhcp_usage : return { 'DHCPUsage' : self . dhcp_usage , 'Name' : self . iqn } else : return self . get_basic_json ( ) | Create JSON data for iSCSI initiator . |
47,896 | def get_json ( self ) : json = { 'DHCPUsage' : self . dhcp_usage , 'AuthenticationMethod' : self . auth_method , } if not self . dhcp_usage : json [ 'Name' ] = self . iqn json [ 'IPv4Address' ] = self . ip json [ 'PortNumber' ] = self . port json [ 'BootLUN' ] = self . lun if self . chap_user : json [ 'ChapUserName' ] ... | Create JSON data for iSCSI target . |
47,897 | def zscale ( data , contrast , min = 100 , max = 60000 ) : import random x = [ ] for i in random . sample ( xrange ( data . shape [ 0 ] ) , 50 ) : for j in random . sample ( xrange ( data . shape [ 1 ] ) , 50 ) : x . append ( data [ i , j ] ) yl = numarray . sort ( numarray . clip ( x , min , max ) ) n = len ( yl ) ym ... | Scale the data cube into the range 0 - 255 |
47,898 | def convert ( self , point ) : x , y = point ( x1 , y1 ) = x - self . x_offset , y - self . y_offset logger . debug ( "converted {} {} ==> {} {}" . format ( x , y , x1 , y1 ) ) return x1 , y1 | Convert a point from one coordinate system to another . |
47,899 | def apply_network ( network , x , chunksize = None ) : network_is_cuda = next ( network . parameters ( ) ) . is_cuda x = torch . from_numpy ( x ) with torch . no_grad ( ) : if network_is_cuda : x = x . cuda ( ) if chunksize is None : return from_var ( network ( x ) ) return np . concatenate ( [ from_var ( network ( x [... | Apply a pytorch network potentially in chunks |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.