<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
  <body bgcolor="#FFFFFF" text="#000000">
    
    <pre style="white-space: pre-wrap; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hi Ricarda, 

first I hope I answer at the right place...

- for the field issue it does not work :
ad['all','star_age2'] and ad[('all','star_age2')] give the same error => <span class="ansicyan" style="box-sizing: border-box; color: rgb(70, 130, 180);"><span class="ansigreen" style="box-sizing: border-box; color: rgb(0, 100, 0);"><span class="ansicyan" style="box-sizing: border-box; color: rgb(70, 130, 180);"><span class="ansigreen" style="box-sizing: border-box; color: rgb(0, 100, 0);"><span class="ansicyan" style="box-sizing: border-box; color: rgb(70, 130, 180);"><span class="ansigreen" style="box-sizing: border-box; color: rgb(0, 100, 0);"><span class="ansiyellow" style="box-sizing: border-box; color: rgb(196, 160, 0);"><span class="ansired" style="box-sizing: border-box; color: rgb(139, 0, 0);">YTFieldTypeNotFound</span>: Could not find field 'all'. 
</span></span></span></span></span></span></span>But I can see in the derived_field_list ('all', 'star_age2') and even ('star', 'star_age2'), with 'star' my particle filter!<pre style="box-sizing: border-box; overflow: auto; font-family: monospace; font-size: 14px; display: block; padding: 0px; margin: 0px; line-height: 17.0000591278076px; word-break: break-all; word-wrap: break-word; color: rgb(0, 0, 0); border: 0px; border-radius: 0px; white-space: pre-wrap; vertical-align: baseline; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);"></pre><pre style="box-sizing: border-box; overflow: auto; font-family: monospace; font-size: 14px; displ
 ay: bloc
 k
; padding: 0px; margin: 0px; line-height: 17.0000591278076px; word-break: break-all; word-wrap: break-word; color: rgb(0, 0, 0); border: 0px; border-radius: 0px; white-space: pre-wrap; vertical-align: baseline; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);">
I have made the update to 3.3-dev

Nicolas
</pre>





Hi Nicolas,

the star ages are indeed a known and unsolved problem in yt when using RAMSES.

Having a quick look at your code it seems fine, you just need one more set of brackets when calling it: ad[('all',’star_age2’)]
Otherwise it looks for the fields “all” and “star_age2” separately. 

Does that help?

Ricarda 

><i> On 14 Jan 2016, at 14:03, Nicolas Gillet <<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.spacepope.org_listinfo.cgi_yt-2Dusers-2Dspacepope.org&d=BQMDaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=hgcBC3x6dKFoTrmFmMYYbKNfiHZlGLKliIidd1LwmHI&m=f8TcwO5DEqPWWJxmAnL-GYeNVx-9RDPaqB4NMwI1YKQ&s=GJQUR5Uupg4sy5JjsKfzxOT-0Xdbgxo4kCGOc_niA1I&e=">nicolas.gillet at etu.unistra.fr</a>> wrote:
</i>><i> 
</i>><i> Hello,
</i>><i> 
</i>><i> I am Nicolas, I am a new YT user. I am working on RAMSES simulations.
</i>><i> 
</i>><i> - First I have noted a "bug" (or misunderstand) in the yt.load of RAMSES data.
</i>><i> It takes all the times of the output as 'code_units' times, which is not the case.
</i>><i> The output times are negative and I think it needs a FLRW integration to be converted in conventional time.
</i>><i> Using directly the 'code_units_time' to convert in cgs time is wrong.
</i>><i> So all the times are false in the loaded yt data, simulation time, particles ages ....
</i>><i> 
</i>><i> - My second question is link to the first point. With ramses there is a tool (getstarlist.f90) that extract only the stars in a .txt file, with the ages in Myr with the proper conversion.
</i>><i> My idea is to load those new data in yt, and creat a new field for particles, with this correct ages.
</i>><i> With the example I creat a filter to isolate the stars from 'all' particles, and it apear in the derived_field_list.
</i>><i> But I do not find a way to creat a new field for this filtered particles and even for the 'all' particles.
</i>><i> 
</i>><i> I would like to have the possibility to have a field ad['star', 'my_own_ages'] or ad['all', 'my_own_ages'].
</i>><i> 
</i>><i> What I have done:
</i>><i> 
</i>><i> ### isolate star particles
</i>><i> def _star(pfilter, data):
</i>><i>     filter = data['all', 'particle_age'] < 0
</i>><i>     return filter
</i>><i> 
</i>><i> add_particle_filter('star', function=_star, filtered_type='all', requires=['particle_age','particle_identifier'])
</i>><i> ds.add_particle_filter('star')
</i>><i> 
</i>><i> ### stars are correctly created ok
</i>><i> 
</i>><i> ### create a global star_age field, not linked to 'all' or 'star'
</i>><i> def _star_age(field, data):
</i>><i>     T = data['particle_age'].in_units('Myr') * 0.
</i>><i>     selec_stars = np.where(data['particle_age'] < 0)[0]
</i>><i>     T[selec_stars] = Stars[5,:] * yt.units.Myr
</i>><i>     return T
</i>><i> 
</i>><i> ds.add_field('star_age', function=_star_age, units='Myr')
</i>><i> 
</i>><i> 
</i>><i> 
</i>><i> What I try:
</i>><i> 
</i>><i> def _star_age2(field, data):
</i>><i>     T = data['all','particle_age'].in_units('Myr') * 0.
</i>><i>     selec_stars = np.where(data['all','particle_age'] < 0) [0]
</i>><i>     T[selec_stars] = Stars[5,:] * yt.units.Myr
</i>><i>     return T
</i>><i> 
</i>><i> ds.add_field(('all','star_age2'), function=_star_age2, units='Myr')
</i>><i> 
</i>><i> ### ('all','star_age2') appear in the derived_field_list but
</i>><i> 
</i>><i> ad['all','star_age2'] => YTFieldTypeNotFound: Could not find field 'all' 
</i>><i> 
</i>><i> 
</i>><i> Thank you for your help,
</i>><i> Nicolas</i></pre>
  </body>
</html>