The municipal court shall have the power to preserve order; to compel the attendance of witnesses; to compel the production of books and papers to be used as evidence; to punish for contempt; to punish witnesses for nonattendance; and to punish all persons who shall counsel, advise, aid, encourage, or intimidate a witness whose testimony is material or desired before the court. The court shall have the power to enforce its judgment by inflicting such penalties as may be provided by the ordinances of the city.