What you're seeing in those print statements is how yt's field detection system works. Before we actually select and return data, we pass your field function fake data to make sure it doesn't raise errors or it doesn't select fields that aren't available for your dataset.
Here's a script I made based on yours that helps explain what's going on:
And here's the output of that script:
I made a couple modifications compared to your script. First, I added a line at the end that selects your new field from a data object, which causes real data to be fed into the field function after field detection completes. I also specified "units='auto'" in the call to add_field. The dimensions keyword is only used when "units='auto'" is set.
You can see that your field function is called twice. First with a `FieldDetector` instance and then the second time with a real yt data object. In general the field function might be called several times before real data is supplied to it. One way I commonly deal with this is the following hack to only see output when the field definition is called with real data:
def NewField(field, data):
q = data[('STAR', 'age')]
if 'FieldDetector' in str(type(data)):
Although more often I use python's debugger via "import pdb; pdb.set_trace()" instead of print statements.