[yt-users] Stars Particles

Matthew Turk matthewturk at gmail.com
Fri Sep 27 03:44:38 PDT 2013


Hi Francia,

On Thu, Sep 26, 2013 at 10:28 AM, Francia Riesco <ff2214 at columbia.edu> wrote:
> Hi Everybody,
>     I am trying to run this example from the cookbook
>
> from yt.mods import *
> from yt.analysis_modules.star_analysis.api import *
> pf = load("data0030")
> # Find all the haloes, and include star particles.
> haloes = HaloFinder(pf, dm_only=False)
> # Set up the spectrum builder.
> spec = SpectrumBuilder(pf, bcdir="/home/user/bc", model="salpeter")
> # Iterate over the haloes.
> for halo in haloes:
>     # Get the pertinent arrays.
>     ct = halo["creation_time"]
>     sm = halo["ParticleMassMsun"]
>     metal = halo["metallicity_fraction"]
>     # Select just the stars.
>     stars = (ct > 0)
>     ct = ct[stars]
>     sm = sm[stars]
>     metal = metal[stars]
>     # Calculate the spectrum.
>     spec.calculate_spectrum(star_mass=sm, star_creation_time=ct,
>     star_metallicity_fraction=metal)
>     # Write out the SED using the default flux normalization.
>     spec.write_out_SED(name="halo%05d.out" % halo.id)
>
> This is my code
>
> http://paste.yt-project.org/show/3885/
>
> But I get this error:
> Link length is 0.001000
> Filling in 3697686 particles
> Number of initial groups:6036
> Number of groups:257
> FOF CPU TIME: 10395.710700 secs
> Found [ -1   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16
> 17
>   18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35
>   36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53
>   54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71
>   72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89
>   90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107
>  108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
>  126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
>  144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
>  162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
>  180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
>  198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
>  216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
>  234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
>  252 253 254 255 256 257] unique groupings
> yt : [INFO     ] 2013-09-25 15:15:27,721 Initializing HOP
> yt : [INFO     ] 2013-09-25 15:15:27,721 Getting particle_position_x using
> ParticleIO
> yt : [INFO     ] 2013-09-25 15:21:16,316 Getting particle_position_y using
> ParticleIO
> yt : [INFO     ] 2013-09-25 15:25:36,923 Getting particle_position_z using
> ParticleIO
> yt : [INFO     ] 2013-09-25 15:29:48,316 Getting ParticleMassMsun using
> ParticleIO
> Copying arrays for 47944939 particles
> Calling hop... 47944939 1.600e+02
> nSmooth = 65 kd->nActive = 47944939
> Building Tree...
> Finding Densities...
> Finding Densest Neighbors...
> Grouping...
> Merging Groups...
> Writing Output...
> All Done!Calling regroup...
> No minimum group size specified.  Assuming 10 particles.
> ngroups = 262744
> yt : [INFO     ] 2013-09-25 15:52:17,649 Parsing outputs
> yt : [INFO     ] 2013-09-25 15:52:24,347 Getting ParticleMassMsun using
> ParticleIO
> yt : [INFO     ] 2013-09-25 15:57:00,506 Getting particle_position_x using
> ParticleIO
> yt : [INFO     ] 2013-09-25 16:01:14,743 Getting particle_position_y using
> ParticleIO
> yt : [INFO     ] 2013-09-25 16:06:14,673 Getting particle_position_z using
> ParticleIO
> Traceback (most recent call last):
>   File "StarsParticleAnalysys.py", line 48, in <module>
>     spec = SpectrumBuilder(data_source, bcdir="/astro/py/",
> model="salpeter")
>   File
> "/astro/yt-dev/yt-x86_64/src/yt-hg/yt/analysis_modules/star_analysis/sfr_spectrum.py",
> line 278, in __init__
>     (100.0 * self._pf.hubble_constant),
> AttributeError: 'AMRRegion' object has no attribute 'hubble_constant'

I think what you want to do is to initialize the SpectrumBuilder with
the pf object:

spec = SpectrumBuilder(pf, bcdir="/astro/py/", model="salpeter")

and then later on, call it with your data_source:

spec.calculate_spectrum(data_source, ...

I've run this on a small dataset and it works for me.  Let us know if
that fixes it,

Matt

>
> Any suggestion?
> Thanks a lot in Advance!
>
>
>
>
> _______________________________________________
> yt-users mailing list
> yt-users at lists.spacepope.org
> http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
>



More information about the yt-users mailing list