A CCP 170.6 challenge to a judge may generally be made at any time before a trial or hearing.  The master calendar exception does not apply when a party is informed of the reassignment of the case to a different judge by a clerk’s email or telephone message because the party cannot immediately respond to the new judicial assignment by proceeding under CCP 170.6 before the master calendar judge.  Also, San Diego’s local rule that made any judge to whom a case was assigned a “master calendar” judge when the case had to be reassigned for trial is invalid as it conflicts with CCP 170.6, which envisions a single department assigning out all or at least many of the cases ready for trial.