Commit 19ddbb08 authored by Shuai Feng's avatar Shuai Feng
Browse files

fit PEP8 bugs

No related merge requests found
Pipeline #7128 failed with stage
in 0 seconds
Showing with 74 additions and 37 deletions
+74 -37
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/csst_ifs_gehong.iml" filepath="$PROJECT_DIR$/.idea/csst_ifs_gehong.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
import numpy as np import numpy as np
class config(): class config():
""" """
The configuration of spectral modeling. The default value is used for ETC calculation. The configuration of spectral modeling. The default value is used for ETC calculation.
...@@ -21,9 +22,9 @@ class config(): ...@@ -21,9 +22,9 @@ class config():
dpix : float, optional dpix : float, optional
Pixel size in the spatial direction, by default 0.2arcsec Pixel size in the spatial direction, by default 0.2arcsec
""" """
def __init__(self, wave_min = 3500.0, wave_max = 10000.0, def __init__(self, wave_min=3500.0, wave_max=10000.0,
dlam = 2.0, inst_fwhm = 0.1, dlam=2.0, inst_fwhm=0.1,
nx = 30, ny = 30, dpix = 0.2): nx=30, ny=30, dpix=0.2):
self.dlam = dlam self.dlam = dlam
self.wave = np.arange(wave_min, wave_max, dlam) self.wave = np.arange(wave_min, wave_max, dlam)
self.wave_min = wave_min self.wave_min = wave_min
......
import astropy.units as u
import numpy as np import numpy as np
from scipy.interpolate import interp1d from .spec1d import StellarContinuum, HII_Region
from .spec1d import *
import astropy.wcs import astropy.wcs
from astropy.io import fits
class Cube3D(): class Cube3D():
""" """
Class of 3-dimentional spectral cube Class of 3-dimentional spectral cube
""" """
def __init__(self, config, stellar_map = None, gas_map = None): def __init__(self, config, stellar_map=None, gas_map=None):
self.config= config self.config = config
self.nx = config.nx self.nx = config.nx
self.ny = config.ny self.ny = config.ny
...@@ -23,30 +23,30 @@ class Cube3D(): ...@@ -23,30 +23,30 @@ class Cube3D():
self.wave0 = np.min(self.wave) self.wave0 = np.min(self.wave)
self.inst_fwhm = config.inst_fwhm self.inst_fwhm = config.inst_fwhm
self.flux = np.zeros((self.nx,self.ny,self.nz)) self.flux = np.zeros((self.nx, self.ny, self.nz))
self.stellar_map = stellar_map self.stellar_map = stellar_map
self.gas_map = gas_map self.gas_map = gas_map
def make_cube(self, stellar_tem = None, hii_tem = None): def make_cube(self, stellar_tem=None, hii_tem=None):
for i in range(self.nx): for i in range(self.nx):
for j in range(self.ny): for j in range(self.ny):
if self.stellar_map is not None: if self.stellar_map is not None:
ss = StellarContinuum(self.config, stellar_tem, mag = self.stellar_map.mag[i,j], ss = StellarContinuum(self.config, stellar_tem, mag=self.stellar_map.mag[i, j],
age = self.stellar_map.age[i,j], feh = self.stellar_map.feh[i,j], age=self.stellar_map.age[i, j], feh=self.stellar_map.feh[i, j],
vel = self.stellar_map.vel[i,j], vdisp = self.stellar_map.vdisp[i,j], vel=self.stellar_map.vel[i, j], vdisp=self.stellar_map.vdisp[i, j],
ebv = self.stellar_map.ebv[i,j]) ebv=self.stellar_map.ebv[i, j])
if self.gas_map is not None: if self.gas_map is not None:
gg = HII_Region(self.config, hii_tem, halpha = self.gas_map.halpha[i,j], gg = HII_Region(self.config, hii_tem, halpha=self.gas_map.halpha[i, j],
logz = self.gas_map.zh[i,j], vel = self.gas_map.vel[i,j], logz=self.gas_map.zh[i, j], vel=self.gas_map.vel[i, j],
vdisp = self.gas_map.vdisp[i,j], ebv = self.gas_map.ebv[i,j]) vdisp=self.gas_map.vdisp[i, j], ebv=self.gas_map.ebv[i, j])
self.flux[i,j,:] = ss.flux + gg.flux self.flux[i, j, :] = ss.flux + gg.flux
else: else:
self.flux[i,j,:] = ss.flux self.flux[i, j, :] = ss.flux
def wcs_info(self): def wcs_info(self):
wcs = fits.Header() # wcs = fits.Header()
wcs_dict = {'CTYPE1': 'WAVE ', wcs_dict = {'CTYPE1': 'WAVE ',
'CUNIT1': 'Angstrom', 'CUNIT1': 'Angstrom',
'CDELT1': self.config.dlam, 'CDELT1': self.config.dlam,
...@@ -62,16 +62,16 @@ class Cube3D(): ...@@ -62,16 +62,16 @@ class Cube3D():
'CDELT3': self.dpix / 3600., 'CDELT3': self.dpix / 3600.,
'CRPIX3': np.round(self.nx / 2.), 'CRPIX3': np.round(self.nx / 2.),
'CRVAL3': 1, 'CRVAL3': 1,
'BUNIT' : '10**(-17)*erg/s/cm**2/Angstrom'} 'BUNIT': '10**(-17)*erg/s/cm**2/Angstrom'}
input_wcs = astropy.wcs.WCS(wcs_dict) input_wcs = astropy.wcs.WCS(wcs_dict)
self.wcs_header = input_wcs.to_header() self.wcs_header = input_wcs.to_header()
def insert_spec(self, spec, dx = 0, dy = 0): def insert_spec(self, spec, dx=0, dy=0):
x0 = np.int(np.round(self.config.nx / 2.)) x0 = np.int(np.round(self.config.nx / 2.))
y0 = np.int(np.round(self.config.ny / 2.)) y0 = np.int(np.round(self.config.ny / 2.))
self.flux[x0 + dx, y0 + dy, :] = self.flux[x0 + dx, y0 + dy, :] + spec.flux self.flux[x0 + dx, y0 + dy, :] = self.flux[x0 + dx, y0 + dy, :] + spec.flux
def savefits(self, filename, path = './'): def savefits(self, filename, path='./'):
hdr = fits.Header() hdr = fits.Header()
...@@ -83,12 +83,12 @@ class Cube3D(): ...@@ -83,12 +83,12 @@ class Cube3D():
hdr['RA'] = 0.0 hdr['RA'] = 0.0
hdr['DEC'] = 0.0 hdr['DEC'] = 0.0
hdu0 = fits.PrimaryHDU(header = hdr) hdu0 = fits.PrimaryHDU(header=hdr)
self.wcs_info() self.wcs_info()
hdr = self.wcs_header hdr = self.wcs_header
hdu1 = fits.ImageHDU(self.flux, header = hdr) hdu1 = fits.ImageHDU(self.flux, header=hdr)
# Output # Output
hdulist = fits.HDUList([hdu0, hdu1]) hdulist = fits.HDUList([hdu0, hdu1])
hdulist.writeto(path + filename, overwrite = True) hdulist.writeto(path + filename, overwrite=True)
\ No newline at end of file \ No newline at end of file
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment