Yes, you are correct. That error is indeed caused by the units loading in AMET. This is because there is a limit of 10 characters to the species unit length in AMET. So, your unit of âparticles/cm3â exceeds the 10 character limit and causes an error.
The first part of this fix for this is fairly simple, which involves increasing the maximum length of the units variable definition in the AMET project_units database table. To do this, youâll need to modify one AMET file. In the R_db_code directory, edit line 180 in the âAQ_add_aq2dbase.Râ script from:
create_units_column â paste(âalter table project_units add column â,units_to_add[i],â varchar(10);â,sep=ââ)
to:
create_units_column â paste(âalter table project_units add column â,units_to_add[i],â varchar(50);â,sep=ââ)
This will increase the maximum length of the units variable from 10 to 50. You could use a value greater or less than 50 if youâd like. It just needs to be large enough to allow all the characters for your units.
The second part of this fix is slightly more involved. Since youâve already created and run this project, the units already exist in the âproject_unitsâ table in the AMET database with a character limit of 10. If you simply ran your code again with the change above, AMET would not recreate the units for that species with the new limit, as it just checks to see if the unit exists for that particular species and project, and if so, it does nothing. And, unfortunately, when you delete a project in AMET, it does not delete anything from the project_units table, which is an oversight on my part and something I will fix in the next version of AMET (more on this in a bit).
So, youâll need to manually edit the species in the project_units table so that it has the increased character limit. To do this, youâll need to log into MySQL directly and issue a few commands.
Generally, to log into the AMET database you can do:
mysql -h [AMET_HOSTNAME] -u [USERNAME] -p
Youâll be prompted for your AMET password for your USERNAME. Once youâve logged into MySQL, go to the database that has your project:
use AMET_DATABASE_NAME;
Once in your database, you can now update the unit definition in the project_units table:
describe project_units;
This is show you the current species definitions in project_units. Youâll see that all the species have a definition of varchar(10). We want to change that to 50.
alter table project_units modify [species_name] varchar(50);
So, for example, to update the units definition for species PM_TOT, you would enter:
alter table project_units modify PM_TOT varchar(50);
describe project_units;
You would now see that PM_TOT has definition of varchar(50).
Once youâve updated the units from the table, you can then run your script again (that was failing previously) and it should work correctly without the error about the data being too long.
I realize that Iâve provided a lot here. Hopefully everything is clear. If you have questions or run into any issues, please let me know, and Iâd be happy to help you directly.
Wyat