这是一个我想读入的名为“galfit.365”的文件。我需要通过python访问这个文件,在“输入菜单文件:”后面找到数字“10”,在“”后面找到数字“39” w。” 之后,我想将这些数字保存到目录中。
我知道一般方法;读入文件,找到相关的子字符串,保存该字符串,然后用 asciitable 写出来。但是,我有点像 Python 新手,所以我不知道从哪里开始。首先,我如何“读入文件”?之后,如何找到我感兴趣的特定字符串值?
# Input menu file: 10f160w39.feedme
# Chi^2/nu = 0.003, Chi^2 = 45.157, Ndof = 16768
================================================================================
# IMAGE and GALFIT CONTROL PARAMETERS
A) NOISE10thousandthsciPHOTOF160w39.fits # Input data image (FITS file)
B) NOISE10thousandthgalsciPHOTOF160w39.fits # Output data image block
C) NOISE10thousandthsigmaPHOTOF160w39.fits # Sigma image name (made from data if blank or "none")
D) arjen_psf_f160w.fits # Input PSF image and (optional) diffusion kernel
E) 1 # PSF fine sampling factor relative to data
F) maskNOISE10thousandthsciPHOTOF160w39.fits # Bad pixel mask (FITS image or ASCII coord list)
G) none # File with parameter constraints (ASCII file)
H) 1 130 1 130 # Image region to fit (xmin xmax ymin ymax)
I) 200 200 # Size of the convolution box (x y)
J) 26.563 # Magnitude photometric zeropoint
K) 0.038 0.038 # Plate scale (dx dy) [arcsec per pixel]
O) regular # Display type (regular, curses, both)
P) 0 # Choose: 0=optimize, 1=model, 2=imgblock, 3=subcomps
# INITIAL FITTING PARAMETERS
#
# For component type, the allowed functions are:
# sersic, expdisk, edgedisk, devauc, king, nuker, psf,
# gaussian, moffat, ferrer, and sky.
#
# Hidden parameters will only appear when they're specified:
# Bn (n=integer, Bending Modes).
# C0 (diskyness/boxyness),
# Fn (n=integer, Azimuthal Fourier Modes).
# R0-R10 (coordinate rotation, for creating spiral structures).
# To, Ti, T0-T10 (truncation function).
#
# ------------------------------------------------------------------------------
# par) par value(s) fit toggle(s) # parameter description
# ------------------------------------------------------------------------------
# Component number: 1
0) sersic # Component type
1) 65.6794 64.2952 1 1 # Position x, y
3) 23.7585 1 # Integrated magnitude
4) 0.0100 1 # R_e (effective radius) [pix]
5) 1.6931 1 # Sersic index n (de Vaucouleurs n=4)
6) 0.0000 0 # -----
7) 0.0000 0 # -----
8) 0.0000 0 # -----
9) 0.6379 1 # Axis ratio (b/a)
10) -2.3601 1 # Position angle (PA) [deg: Up=0, Left=90]
Z) 0 # Skip this model in output image? (yes=1, no=0)
# Component number: 2
0) sky # Component type
1) 6.853e-05 1 # Sky background at center of fitting region [ADUs]
2) 0.000e+00 0 # dsky/dx (sky gradient in x) [ADUs/pix]
3) 0.000e+00 0 # dsky/dy (sky gradient in y) [ADUs/pix]
Z) 0 # Skip this model in output image? (yes=1, no=0)
================================================================================