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


Python AstroData.filename方法代码示例

本文整理汇总了Python中astrodata.AstroData.filename方法的典型用法代码示例。如果您正苦于以下问题:Python AstroData.filename方法的具体用法?Python AstroData.filename怎么用?Python AstroData.filename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在astrodata.AstroData的用法示例。


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

示例1: recover

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import filename [as 别名]
 def recover(self):
     log.debug("OufileETIFile recover()")
     ad = AstroData(self.tmp_name, mode="update")
     ad.filename = self.ad_name
     ad = gemini_tools.obsmode_del(ad)
     log.fullinfo(self.tmp_name + " was loaded into memory")
     return ad
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:9,代码来源:gemcombinefile.py

示例2: recover

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import filename [as 别名]
 def recover(self):
     log.debug("OutAtList recover()")
     adlist = []
     for i, tmpname in enumerate(self.diskoutlist):
         ad = AstroData(tmpname, mode="update")
         ad.filename = self.ad_name[i]
         ad = gemini_tools.obsmode_del(ad)
         adlist.append(ad)
         log.fullinfo(tmpname + " was loaded into memory")
     return adlist
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:12,代码来源:gsextractfile.py

示例3: recover

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import filename [as 别名]
 def recover(self):
     log.debug("OutAtList recover()")
     adlist = []
     for i, tmpname in enumerate(self.diskoutlist):
         ad = AstroData(tmpname, mode="update")
         ad.filename = self.ad_name[i]
         ad = gemini_tools.obsmode_del(ad)
         # Read the database back in, if it exists
         try:
             ad = gemini_tools.read_database(
                 ad, database_name=self.database_name, 
                 input_name=self.tmpin_name[i], 
                 output_name=ad.phu_get_key_value("ORIGNAME"))
         except:
             pass
         adlist.append(ad)
         log.fullinfo(tmpname + " was loaded into memory")
     return adlist
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:20,代码来源:gstransformfile.py

示例4: test_attr_filename_2

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import filename [as 别名]
def test_attr_filename_2():
    """ setter """
    ad = AstroData(TESTFILE)
    ad.filename = "FOO.fits"
    assert ad.filename == "FOO.fits"
开发者ID:mmorage,项目名称:DRAGONS,代码行数:7,代码来源:test_AstroDataAPI.py

示例5: _calculate_var

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import filename [as 别名]
    def _calculate_var(self, adinput=None, add_read_noise=False,
                       add_poisson_noise=False):
        """
        The _calculate_var helper function is used to calculate the variance
        and add a variance extension to the single input AstroData object.
        
        """
        # Instantiate the log
        log = logutils.get_logger(__name__)
        
        # Get the gain and the read noise using the appropriate descriptors.
        gain_dv = adinput.gain()
        read_noise_dv = adinput.read_noise()

        # Only check read_noise here as gain descriptor is only used if units
        # are in ADU
        if read_noise_dv.is_none() and add_read_noise:
            # The descriptor functions return None if a value cannot be found
            # and stores the exception info. Re-raise the exception.
            if hasattr(adinput, "exception_info"):
                raise adinput.exception_info
            else:
                raise Errors.InputError("read_noise descriptor "
                                        "returned None...\n%s"
                                        % (read_noise_dv.info()))
            
        # Set the data type of the final variance array
        var_dtype = np.dtype(np.float32)
        
        # Loop over the science extensions in the dataset
        for ext in adinput[SCI]:
            extver = ext.extver()
            bunit  = ext.get_key_value("BUNIT")

            if bunit == "adu":
                # Get the gain value using the appropriate descriptor. The gain
                # is only used if the units are in ADU. Raise if gain is None
                gain = gain_dv.get_value(extver=extver)
                if gain is not None:
                    log.fullinfo("Gain for %s[%s,%d] = %f"
                                 % (adinput.filename, SCI, extver, gain))
                elif add_read_noise or add_poisson_noise:
                    err_msg = ("Gain for %s[%s,%d] is None. Cannot calculate "
                                "variance properly. Setting to zero."
                                % (adinput.filename, SCI, extver))
                    raise Errors.InputError(err_msg)
                
                units = "ADU"
            elif bunit == "electron" or bunit == "electrons":
                units = "electrons"
            else:
                # Perhaps something more sensible should be done here?
                raise Errors.InputError("No units found. Not calculating "
                                        "variance.")
            
            if add_read_noise:
                # Get the read noise value (in units of electrons) using the
                # appropriate descriptor. The read noise is only used if
                # add_read_noise is True
                read_noise = read_noise_dv.get_value(extver=extver)
                if read_noise is not None:
                    log.fullinfo("Read noise for %s[%s,%d] = %f"
                                 % (adinput.filename, SCI, extver, read_noise))
                    
                    # Determine the variance value to use when calculating the
                    # read noise component of the variance.
                    read_noise_var_value = read_noise
                    if units == "ADU":
                        read_noise_var_value = read_noise / gain
                    
                    # Add the read noise component of the variance to a zeros
                    # array that is the same size as the pixel data in the
                    # science extension
                    log.fullinfo("Calculating the read noise component of the "
                                 "variance in %s" % units)
                    var_array_rn = np.add(
                      np.zeros(ext.data.shape), (read_noise_var_value)**2)
                else:
                    logwarning("Read noise for %s[%s,%d] is None. Setting to "
                               "zero" % (adinput.filename, SCI, extver))
                    var_array_rn = np.zeros(ext.data.shape)
                    
            if add_poisson_noise:
                # Determine the variance value to use when calculating the
                # poisson noise component of the variance
                poisson_noise_var_value = ext.data
                if units == "ADU":
                    poisson_noise_var_value = ext.data / gain
                
                # Calculate the poisson noise component of the variance. Set
                # pixels that are less than or equal to zero to zero.
                log.fullinfo("Calculating the poisson noise component of "
                             "the variance in %s" % units)
                var_array_pn = np.where(
                  ext.data > 0, poisson_noise_var_value, 0)
            
            # Create the final variance array
            if add_read_noise and add_poisson_noise:
                var_array_final = np.add(var_array_rn, var_array_pn)
            
#.........这里部分代码省略.........
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:103,代码来源:primitives_standardize.py

示例6: addDQ

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import filename [as 别名]
    def addDQ(self, rc):
        """
        This primitive is used to add a DQ extension to the input AstroData
        object. The value of a pixel in the DQ extension will be the sum of the
        following: (0=good, 1=bad pixel (found in bad pixel mask), 2=pixel is
        in the non-linear regime, 4=pixel is saturated). This primitive will
        trim the BPM to match the input AstroData object(s).
        
        :param bpm: The file name, including the full path, of the BPM(s) to be
                    used to flag bad pixels in the DQ extension. If only one
                    BPM is provided, that BPM will be used to flag bad pixels
                    in the DQ extension for all input AstroData object(s). If
                    more than one BPM is provided, the number of BPMs must
                    match the number of input AstroData objects. If no BPM is
                    provided, the primitive will attempt to determine an
                    appropriate BPM.
        :type bpm: string or list of strings
        """
        # Instantiate the log
        log = logutils.get_logger(__name__)
        
        # Log the standard "starting primitive" debug message
        log.debug(gt.log_message("primitive", "addDQ", "starting"))
        
        # Define the keyword to be used for the time stamp for this primitive
        timestamp_key = self.timestamp_keys["addDQ"]
        
        # Initialize the list of output AstroData objects
        adoutput_list = []
        
        # Set the data type of the data quality array
        # It can be uint8 for now, it will get converted up as we assign higher bit values
        # shouldn't need to force it up to 16bpp yet.
        dq_dtype = np.dtype(np.uint8)
        #dq_dtype = np.dtype(np.uint16)
        
        # Get the input AstroData objects
        adinput = rc.get_inputs_as_astrodata()
        
        # Loop over each input AstroData object in the input list
        for ad in adinput:
            
            # Check whether the addDQ primitive has been run previously
            if ad.phu_get_key_value(timestamp_key):
                log.warning("No changes will be made to %s, since it has "
                            "already been processed by addDQ" % ad.filename)
                
                # Append the input AstroData object to the list of output
                # AstroData objects without further processing
                adoutput_list.append(ad)
                continue
            
            # Parameters specified on the command line to reduce are converted
            # to strings, including None
            ##M What about if a user doesn't want to add a BPM at all?
            ##M Are None's not converted to Nonetype from the command line?
            if rc["bpm"] and rc["bpm"] != "None":
                # The user supplied an input to the bpm parameter
                bpm = rc["bpm"]
            else:
                # The user did not supply an input to the bpm parameter, so try
                # to find an appropriate one. Get the dictionary containing the
                # list of BPMs for all instruments and modes.
                all_bpm_dict = Lookups.get_lookup_table("Gemini/BPMDict",
                                                        "bpm_dict")
                
                # Call the _get_bpm_key helper function to get the key for the
                # lookup table 
                key = self._get_bpm_key(ad)
                
                # Get the appropriate BPM from the look up table
                if key in all_bpm_dict:
                    bpm = lookup_path(all_bpm_dict[key])
                else:
                    bpm = None
                    log.warning("No BPM found for %s, no BPM will be "
                                "included" % ad.filename)

            # Ensure that the BPMs are AstroData objects
            bpm_ad = None
            if bpm is not None:
                log.fullinfo("Using %s as BPM" % str(bpm))
                if isinstance(bpm, AstroData):
                    bpm_ad = bpm
                else:
                    bpm_ad = AstroData(bpm)
                    ##M Do we want to fail here depending on context?
                    if bpm_ad is None:
                        log.warning("Cannot convert %s into an AstroData "
                                    "object, no BPM will be added" % bpm)

            final_bpm = None
            if bpm_ad is not None:
                # Clip the BPM data to match the size of the input AstroData
                # object science and pad with overscan region, if necessary
                final_bpm = gt.clip_auxiliary_data(adinput=ad, aux=bpm_ad,
                                                   aux_type="bpm")[0]

            # Get the non-linear level and the saturation level using the
            # appropriate descriptors - Individual values get checked in the
#.........这里部分代码省略.........
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:103,代码来源:primitives_standardize.py

示例7: makeFringeFrame

# 需要导入模块: from astrodata import AstroData [as 别名]
# 或者: from astrodata.AstroData import filename [as 别名]
    def makeFringeFrame(self,rc):

        # Instantiate the log
        log = gemLog.getGeminiLog(logType=rc["logType"],
                                  logLevel=rc["logLevel"])

        # Log the standard "starting primitive" debug message
        log.debug(gt.log_message("primitive", "makeFringeFrame", 
                                 "starting"))

        # Initialize the list of output AstroData objects
        adoutput_list = []

        # Check for at least 3 input frames
        adinput = rc.get_inputs_as_astrodata()
        if len(adinput)<3:
            log.stdinfo('Fewer than 3 frames provided as input. ' +
                        'Not making fringe frame.')

            # Report the empty list to the reduction context
            rc.report_output(adoutput_list)
        
        else:
            rc.run("correctBackgroundToReferenceImage"\
                       "(remove_zero_level=True)")

            # If needed, do a rough median on all frames, subtract,
            # and then redetect to help distinguish sources from fringes
            sub_med = rc["subtract_median_image"]
            if sub_med:
                adinput = rc.get_inputs_as_astrodata()

                # Get data by science extension
                data = {}
                for ad in adinput:
                    for sciext in ad["SCI"]:
                        key = (sciext.extname(),sciext.extver())
                        if data.has_key(key):
                            data[key].append(sciext.data)
                        else:
                            data[key] = [sciext.data]


                # Make a median image for each extension
                import pyfits as pf
                median_ad = AstroData()
                median_ad.filename = gt.filename_updater(
                    adinput=adinput[0], suffix="_stack_median", strip=True)
                for key in data:
                    med_data = np.median(np.dstack(data[key]),axis=2)
                    hdr = pf.Header()
                    ext = AstroData(data=med_data, header=hdr)
                    ext.rename_ext(key)
                    median_ad.append(ext)

                # Subtract the median image
                rc["operand"] = median_ad
                rc.run("subtract")

                # Redetect to get a good object mask
                rc.run("detectSources")

                # Add the median image back in to the input
                rc.run("add")

            # Add the object mask into the DQ plane
            rc.run("addObjectMaskToDQ")
            
            # Stack frames with masking from DQ plane
            rc.run("stackFrames(operation=%s)" % rc["operation"])

        yield rc
开发者ID:pyrrho314,项目名称:recipesystem,代码行数:74,代码来源:primitives_GMOS_IMAGE.py


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