calculate temp function