[yt-svn] commit/yt: 4 new changesets
Bitbucket
commits-noreply at bitbucket.org
Tue Nov 27 14:22:25 PST 2012
4 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/7a96cb818bae/
changeset: 7a96cb818bae
branch: yt
user: Christopher Moody
date: 2012-11-27 18:38:13
summary: setup conversion factors for particle velocity and mass
affected #: 1 file
diff -r 01662d3efcd365c5477bb939ee376164622c982e -r 7a96cb818bae8979632f1e7f5282559a24184693 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -583,12 +583,14 @@
self.conversion_factors = cf
for ax in 'xyz':
- self.conversion_factors["%s-velocity" % ax] = v0/aexpn
+ self.conversion_factors["%s-velocity" % ax] = cf['Velocity']
+ self.conversion_factors["particle_velcity_%s"%ax] = cf['Velocity']
for unit in sec_conversion.keys():
self.time_units[unit] = 1.0 / sec_conversion[unit]
for particle_field in particle_fields:
self.conversion_factors[particle_field] = 1.0
self.conversion_factors['particle_creation_time'] = 31556926.0
+ self.conversion_factors['particle_mass']=cf['Mass']
self.conversion_factors['Msun'] = 5.027e-34
def _parse_parameter_file(self):
https://bitbucket.org/yt_analysis/yt/changeset/d0e15acbacaf/
changeset: d0e15acbacaf
branch: yt
user: Christopher Moody
date: 2012-11-27 22:35:11
summary: particle masses and velocity units are correct now
affected #: 1 file
diff -r 7a96cb818bae8979632f1e7f5282559a24184693 -r d0e15acbacaf0db49d34440203ed93dae5d4c700 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -332,9 +332,7 @@
if not self.pf.skip_particles and self.pf.file_particle_data:
lspecies = self.pf.parameters['lspecies']
wspecies = self.pf.parameters['wspecies']
- um = self.pf.conversion_factors['Mass'] #mass units in g
- uv = self.pf.conversion_factors['Velocity'] #mass units in g
- self.pf.particle_position,self.pf.particle_velocity = \
+ self.pf.particle_position,self.pf.particle_velocity= \
read_particles(self.pf.file_particle_data,
self.pf.parameters['Nrow'])
nparticles = lspecies[-1]
@@ -343,17 +341,18 @@
self.pf.particle_position = self.pf.particle_position[:nparticles]
self.pf.particle_velocity = self.pf.particle_velocity[:nparticles]
self.pf.particle_position /= self.pf.domain_dimensions
- self.pf.particle_velocity = self.pf.particle_velocity
- self.pf.particle_velocity *= uv #to proper cm/s
+ self.pf.particle_type = np.zeros(nparticles,dtype='int')
+ self.pf.particle_mass = np.zeros(nparticles,dtype='float64')
self.pf.particle_star_index = len(wspecies)-1
- self.pf.particle_type = np.zeros(nparticles,dtype='int')
- self.pf.particle_mass = np.zeros(nparticles,dtype='float32')
a=0
for i,(b,m) in enumerate(zip(lspecies,wspecies)):
if i == self.pf.particle_star_index:
+ assert m==0.0
sa,sb = a,b
+ else:
+ assert m>0.0
self.pf.particle_type[a:b] = i #particle type
- self.pf.particle_mass[a:b] = m*um #mass in grams
+ self.pf.particle_mass[a:b] = m #mass in code units
a=b
if not self.pf.skip_stars and self.pf.file_particle_stars:
(nstars_rs,), mass, imass, tbirth, metallicity1, metallicity2, \
@@ -380,8 +379,9 @@
ages = spread_ages(ages)
idx = self.pf.particle_type == self.pf.particle_star_index
for psf in particle_star_fields:
- setattr(self.pf,psf,
- np.zeros(nparticles,dtype='float32'))
+ if getattr(self.pf,psf,None) is None:
+ setattr(self.pf,psf,
+ np.zeros(nparticles,dtype='float64'))
self.pf.particle_age[sa:sb] = ages
self.pf.particle_mass[sa:sb] = mass
self.pf.particle_mass_initial[sa:sb] = imass
@@ -558,19 +558,30 @@
aexpn = self.parameters["aexpn"]
hubble = self.parameters['hubble']
+ cf = defaultdict(lambda: 1.0)
r0 = boxh/ng
P0= 4.697e-16 * Om0**2.0 * r0**2.0 * hubble**2.0
T_0 = 3.03e5 * r0**2.0 * wmu * Om0 # [K]
S_0 = 52.077 * wmu**(5.0/3.0)
S_0 *= hubble**(-4.0/3.0)*Om0**(1.0/3.0)*r0**2.0
- v0 = r0 * 50.0*1.0e5 * np.sqrt(self.omega_matter) #cm/s
+ #v0 = r0 * 50.0*1.0e5 * np.sqrt(self.omega_matter) #cm/s
+ v0 = 50.0*r0*np.sqrt(Om0)
t0 = r0/v0
- rho0 = 1.8791e-29 * hubble**2.0 * self.omega_matter
+ #rho0 = 1.8791e-29 * hubble**2.0 * self.omega_matter
+ rho0 = 2.776e11 * hubble**2.0 * Om0
tr = 2./3. *(3.03e5*r0**2.0*wmu*self.omega_matter)*(1.0/(aexpn**2))
aM0 = rho0 * (boxh/hubble)**3.0 / ng**3.0
+ cf['r0']=r0
+ cf['P0']=P0
+ cf['T_0']=T_0
+ cf['S_0']=S_0
+ cf['v0']=v0
+ cf['t0']=t0
+ cf['rho0']=rho0
+ cf['tr']=tr
+ cf['aM0']=aM0
#factors to multiply the native code units to CGS
- cf = defaultdict(lambda: 1.0)
cf['Pressure'] = P0 #already cgs
cf['Velocity'] = v0/aexpn*1.0e5 #proper cm/s
cf["Mass"] = aM0 * 1.98892e33
@@ -582,15 +593,15 @@
self.cosmological_simulation = True
self.conversion_factors = cf
+ for particle_field in particle_fields:
+ self.conversion_factors[particle_field] = 1.0
for ax in 'xyz':
- self.conversion_factors["%s-velocity" % ax] = cf['Velocity']
- self.conversion_factors["particle_velcity_%s"%ax] = cf['Velocity']
+ self.conversion_factors["%s-velocity" % ax] = 1.0
+ self.conversion_factors["particle_velocity_%s"%ax] = cf['Velocity']
for unit in sec_conversion.keys():
self.time_units[unit] = 1.0 / sec_conversion[unit]
- for particle_field in particle_fields:
- self.conversion_factors[particle_field] = 1.0
+ self.conversion_factors['particle_mass'] = cf['Mass']
self.conversion_factors['particle_creation_time'] = 31556926.0
- self.conversion_factors['particle_mass']=cf['Mass']
self.conversion_factors['Msun'] = 5.027e-34
def _parse_parameter_file(self):
@@ -603,7 +614,6 @@
self.parameters = {}
self.unique_identifier = \
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
- header_vals = {}
self.parameters.update(constants)
with open(self.file_amr,'rb') as f:
amr_header_vals = _read_struct(f,amr_header_struct)
@@ -639,7 +649,14 @@
mylog.info("Discovered %i species of particles",len(ls_nonzero))
mylog.info("Particle populations: "+'%1.1e '*len(ls_nonzero),
*ls_nonzero)
- self.parameters.update(particle_header_vals)
+ for k,v in particle_header_vals.items():
+ if k in self.parameters.keys():
+ if not self.parameters[k] == v:
+ mylog.info("Inconsistent parameter %s %1.1e %1.1e",k,v,
+ self.parameters[k])
+ else:
+ self.parameters[k]=v
+ self.parameters_particles = particle_header_vals
#setup standard simulation yt expects to see
self.current_redshift = self.parameters["aexpn"]**-1.0 - 1.0
https://bitbucket.org/yt_analysis/yt/changeset/e15e521170a3/
changeset: e15e521170a3
branch: yt
user: Christopher Moody
date: 2012-11-27 23:12:03
summary: typing the particle index; this cut down a 100-second loop to milliseconds...
affected #: 1 file
diff -r d0e15acbacaf0db49d34440203ed93dae5d4c700 -r e15e521170a3eb9d326586403d53a99f1af99ae9 yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
@@ -244,6 +244,7 @@
cdef np.float64_t conv[6], left_edge[6]
cdef np.ndarray[np.int64_t, ndim=1] arri
cdef np.ndarray[np.float64_t, ndim=1] arr
+ cdef unsigned long long pi,fi,i
pf = rh.tsl.next()
print 'reading from particle filename %s: %s'%(filename,pf.basename)
block = int(str(filename).rsplit(".")[-1])
https://bitbucket.org/yt_analysis/yt/changeset/271a1313d9be/
changeset: 271a1313d9be
branch: yt
user: MatthewTurk
date: 2012-11-27 23:22:21
summary: Merged in juxtaposicion/yt-dev (pull request #351)
affected #: 2 files
diff -r 4a6750aa470968444770411d1dce3b1d10b77a16 -r 271a1313d9be206a52ab3b3627089e49a45b0c70 yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
--- a/yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
+++ b/yt/analysis_modules/halo_finding/rockstar/rockstar_interface.pyx
@@ -244,6 +244,7 @@
cdef np.float64_t conv[6], left_edge[6]
cdef np.ndarray[np.int64_t, ndim=1] arri
cdef np.ndarray[np.float64_t, ndim=1] arr
+ cdef unsigned long long pi,fi,i
pf = rh.tsl.next()
print 'reading from particle filename %s: %s'%(filename,pf.basename)
block = int(str(filename).rsplit(".")[-1])
diff -r 4a6750aa470968444770411d1dce3b1d10b77a16 -r 271a1313d9be206a52ab3b3627089e49a45b0c70 yt/frontends/art/data_structures.py
--- a/yt/frontends/art/data_structures.py
+++ b/yt/frontends/art/data_structures.py
@@ -332,9 +332,7 @@
if not self.pf.skip_particles and self.pf.file_particle_data:
lspecies = self.pf.parameters['lspecies']
wspecies = self.pf.parameters['wspecies']
- um = self.pf.conversion_factors['Mass'] #mass units in g
- uv = self.pf.conversion_factors['Velocity'] #mass units in g
- self.pf.particle_position,self.pf.particle_velocity = \
+ self.pf.particle_position,self.pf.particle_velocity= \
read_particles(self.pf.file_particle_data,
self.pf.parameters['Nrow'])
nparticles = lspecies[-1]
@@ -343,17 +341,18 @@
self.pf.particle_position = self.pf.particle_position[:nparticles]
self.pf.particle_velocity = self.pf.particle_velocity[:nparticles]
self.pf.particle_position /= self.pf.domain_dimensions
- self.pf.particle_velocity = self.pf.particle_velocity
- self.pf.particle_velocity *= uv #to proper cm/s
+ self.pf.particle_type = np.zeros(nparticles,dtype='int')
+ self.pf.particle_mass = np.zeros(nparticles,dtype='float64')
self.pf.particle_star_index = len(wspecies)-1
- self.pf.particle_type = np.zeros(nparticles,dtype='int')
- self.pf.particle_mass = np.zeros(nparticles,dtype='float32')
a=0
for i,(b,m) in enumerate(zip(lspecies,wspecies)):
if i == self.pf.particle_star_index:
+ assert m==0.0
sa,sb = a,b
+ else:
+ assert m>0.0
self.pf.particle_type[a:b] = i #particle type
- self.pf.particle_mass[a:b] = m*um #mass in grams
+ self.pf.particle_mass[a:b] = m #mass in code units
a=b
if not self.pf.skip_stars and self.pf.file_particle_stars:
(nstars_rs,), mass, imass, tbirth, metallicity1, metallicity2, \
@@ -380,8 +379,9 @@
ages = spread_ages(ages)
idx = self.pf.particle_type == self.pf.particle_star_index
for psf in particle_star_fields:
- setattr(self.pf,psf,
- np.zeros(nparticles,dtype='float32'))
+ if getattr(self.pf,psf,None) is None:
+ setattr(self.pf,psf,
+ np.zeros(nparticles,dtype='float64'))
self.pf.particle_age[sa:sb] = ages
self.pf.particle_mass[sa:sb] = mass
self.pf.particle_mass_initial[sa:sb] = imass
@@ -558,19 +558,30 @@
aexpn = self.parameters["aexpn"]
hubble = self.parameters['hubble']
+ cf = defaultdict(lambda: 1.0)
r0 = boxh/ng
P0= 4.697e-16 * Om0**2.0 * r0**2.0 * hubble**2.0
T_0 = 3.03e5 * r0**2.0 * wmu * Om0 # [K]
S_0 = 52.077 * wmu**(5.0/3.0)
S_0 *= hubble**(-4.0/3.0)*Om0**(1.0/3.0)*r0**2.0
- v0 = r0 * 50.0*1.0e5 * np.sqrt(self.omega_matter) #cm/s
+ #v0 = r0 * 50.0*1.0e5 * np.sqrt(self.omega_matter) #cm/s
+ v0 = 50.0*r0*np.sqrt(Om0)
t0 = r0/v0
- rho0 = 1.8791e-29 * hubble**2.0 * self.omega_matter
+ #rho0 = 1.8791e-29 * hubble**2.0 * self.omega_matter
+ rho0 = 2.776e11 * hubble**2.0 * Om0
tr = 2./3. *(3.03e5*r0**2.0*wmu*self.omega_matter)*(1.0/(aexpn**2))
aM0 = rho0 * (boxh/hubble)**3.0 / ng**3.0
+ cf['r0']=r0
+ cf['P0']=P0
+ cf['T_0']=T_0
+ cf['S_0']=S_0
+ cf['v0']=v0
+ cf['t0']=t0
+ cf['rho0']=rho0
+ cf['tr']=tr
+ cf['aM0']=aM0
#factors to multiply the native code units to CGS
- cf = defaultdict(lambda: 1.0)
cf['Pressure'] = P0 #already cgs
cf['Velocity'] = v0/aexpn*1.0e5 #proper cm/s
cf["Mass"] = aM0 * 1.98892e33
@@ -582,12 +593,14 @@
self.cosmological_simulation = True
self.conversion_factors = cf
+ for particle_field in particle_fields:
+ self.conversion_factors[particle_field] = 1.0
for ax in 'xyz':
- self.conversion_factors["%s-velocity" % ax] = v0/aexpn
+ self.conversion_factors["%s-velocity" % ax] = 1.0
+ self.conversion_factors["particle_velocity_%s"%ax] = cf['Velocity']
for unit in sec_conversion.keys():
self.time_units[unit] = 1.0 / sec_conversion[unit]
- for particle_field in particle_fields:
- self.conversion_factors[particle_field] = 1.0
+ self.conversion_factors['particle_mass'] = cf['Mass']
self.conversion_factors['particle_creation_time'] = 31556926.0
self.conversion_factors['Msun'] = 5.027e-34
@@ -601,7 +614,6 @@
self.parameters = {}
self.unique_identifier = \
int(os.stat(self.parameter_filename)[stat.ST_CTIME])
- header_vals = {}
self.parameters.update(constants)
with open(self.file_amr,'rb') as f:
amr_header_vals = _read_struct(f,amr_header_struct)
@@ -637,7 +649,14 @@
mylog.info("Discovered %i species of particles",len(ls_nonzero))
mylog.info("Particle populations: "+'%1.1e '*len(ls_nonzero),
*ls_nonzero)
- self.parameters.update(particle_header_vals)
+ for k,v in particle_header_vals.items():
+ if k in self.parameters.keys():
+ if not self.parameters[k] == v:
+ mylog.info("Inconsistent parameter %s %1.1e %1.1e",k,v,
+ self.parameters[k])
+ else:
+ self.parameters[k]=v
+ self.parameters_particles = particle_header_vals
#setup standard simulation yt expects to see
self.current_redshift = self.parameters["aexpn"]**-1.0 - 1.0
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list