<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Nicolas,<div class=""><br class=""></div><div class="">the star ages are indeed a known and unsolved problem in yt when using RAMSES.</div><div class=""><br class=""></div><div class="">Having a quick look at your code it seems fine, you just need one more set of brackets when calling it: <font color="#cc0000" class="">ad[('all',’star_age2’)]</font></div><div class="">Otherwise it looks for the fields “all” and “star_age2” separately. </div><div class=""><span style="color: rgb(204, 0, 0);" class=""><br class=""></span></div><div class="">Does that help?</div><div class=""><span style="color: rgb(204, 0, 0);" class=""><br class=""></span></div><div class="">Ricarda<span style="color: rgb(204, 0, 0);" class=""> </span></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 14 Jan 2016, at 14:03, Nicolas Gillet <<a href="mailto:nicolas.gillet@etu.unistra.fr" class="">nicolas.gillet@etu.unistra.fr</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">

  
  <div bgcolor="#FFFFFF" text="#000000" class="">
    Hello,<br class="">
    <br class="">
    I am Nicolas, I am a new YT user. I am working on RAMSES
    simulations.<br class="">
    <br class="">
    - First I have noted a "bug" (or misunderstand) in the yt.load of
    RAMSES data.<br class="">
    It takes all the times of the output as 'code_units' times, which is
    not the case.<br class="">
    The output times are negative and I think it needs a FLRW
    integration to be converted in conventional time.<br class="">
    Using directly the 'code_units_time' to convert in cgs time is
    wrong.<br class="">
    So all the times are false in the loaded yt data, simulation time,
    particles ages ....<br class="">
    <br class="">
    - 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.<br class="">
    My idea is to load those new data in yt, and creat a new field for
    particles, with this correct ages.<br class="">
    With the example I creat a filter to isolate the stars from 'all'
    particles, and it apear in the derived_field_list.<br class="">
    But I do not find a way to creat a new field for this filtered
    particles and even for the 'all' particles.<br class="">
    <br class="">
    I would like to have the possibility to have a field ad['star',
    'my_own_ages'] or ad['all', 'my_own_ages'].<br class="">
    <br class="">
    What I have done:<br class="">
    <br class="">
    <font color="#3333ff" class="">### isolate star particles<br class="">
      def _star(pfilter, data):<br class="">
          filter = data['all', 'particle_age'] < 0<br class="">
          return filter<br class="">
      <br class="">
      add_particle_filter('star', function=_star, filtered_type='all',
      requires=['particle_age','particle_identifier'])<br class="">
      ds.add_particle_filter('star')<br class="">
      <br class="">
      ### stars are correctly created ok<br class="">
      <br class="">
      ### create a global star_age field, not linked to 'all' or 'star'<br class="">
      def _star_age(field, data):<br class="">
          T = data['particle_age'].in_units('Myr') * 0.<br class="">
          selec_stars = np.where(data['particle_age'] < 0)[0]<br class="">
          T[selec_stars] = Stars[5,:] * yt.units.Myr<br class="">
          return T<br class="">
      <br class="">
      ds.add_field('star_age', function=_star_age, units='Myr')</font><br class="">
    <br class="">
    <br class="">
    <br class="">
    What I try:<br class="">
    <font color="#cc0000" class=""><br class="">
      def _star_age2(field, data):<br class="">
          T = data['all','particle_age'].in_units('Myr') * 0.<br class="">
          selec_stars = np.where(data['all','particle_age'] < 0) [0]<br class="">
          T[selec_stars] = Stars[5,:] * yt.units.Myr<br class="">
          return T<br class="">
      <br class="">
      ds.add_field(('all','star_age2'), function=_star_age2,
      units='Myr')<br class="">
      <br class="">
      ### ('all','star_age2') appear in the derived_field_list</font>
    but<br class="">
    <br class="">
    <font color="#cc0000" class="">ad['all','star_age2'] => </font><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>
    
    <br class="">
    <br class="">
    <br class="">
    Thank you for your help,<br class="">
    Nicolas<br class="">
    <br class="">
    <br class="">
    <br class="">
  </div>

_______________________________________________<br class="">yt-users mailing list<br class=""><a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org<br class=""></div></blockquote></div><br class=""></div></body></html>